vs code中C++ cout输出中文乱码
作者:野牛程序员:2023-11-16 08:58:25 C++阅读 2854
通过SetConsoleOutputCP函数修改编码:
1、引入头文件:
#include <Windows.h>
2、代码中调用
SetConsoleOutputCP(CP_UTF8);
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
SetConsoleOutputCP(CP_UTF8);
double number = 10.5; // 要判断的数
bool isInteger = (number == static_cast<int>(number));
if (isInteger)
{
cout << "数字是整数" << endl;
}
else
{
cout << "数字不是整数" << endl;
}
return 0;
}野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892

- 上一篇:C语言输入矩形的长和宽,计算该矩形的面积
- 下一篇:C++读取字节中的某一位
