我的代码就这么简单:
#include <iostream>
using namespace std;
//Some codes here...
bool somefunction(){
cout<<"单元格";
return false;
}
这就是我得到的:
error C2143: syntax error: missing ';' before 'return'; error C2001: newline is constant;
此外,如果我将"元格"
改成英文版本,如"cell",它会完美运行;
最佳答案
编译器错误表明您的编译器不支持源代码中的 Unicode 字符。您必须转义它们,使用宽字符常量,以及 wcout
:
wcout << L"\x5355\x5143\x683c";
如果您需要以特定编码(例如 gb2312)输出字符,请在字符串文字中使用该编码:
cout << "\xb5\xa5\xd4\xaa\xb8\xf1"; // string encoded with GB2312
关于c++ - "cout"无法使用汉字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12469068/