常见于Windows DevC++运行程序时。
将代码改成这样可解决:
/*
你的代码
*/
#ifdef _WIN32
#include <windows.h>
#endif
int main() {
// 设置控制台编码
#ifdef _WIN32
SetConsoleOutputCP(65001); // 设置输出代码页为UTF-8
SetConsoleCP(65001); // 设置输入代码页为UTF-8
#endif
/*
你的代码
*/
}
并在DevC++里保存文件为UTF-8格式。