当前位置:首页 C++ > 正文

vs code中C++ cout输出中文乱码

作者:野牛程序员:2023-11-16 08:58:25 C++阅读 2667

通过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
野牛程序员教少儿编程与信息学竞赛-微信|电话:15892516892
相关推荐

最新推荐

热门点击