#include<iostream>
#include<stdlib.h>
void main(){
wchar_t* p1 = L"123456";
std::cout << p1 << std::endl;
wchar_t* p2 = L"你好世界123455";
std::cout << p2 << std::endl;
system("pause");
}
上述程序控制台输出结果为:
123456
请按任意键继续. . .
为了解决上述问题,采用以下解决方案:
#include<iostream>
#include<stdlib.h>
#include<locale>
void main(){
setlocale(LC_ALL,"chs");
wchar_t* p1 = L"123456";
std::cout << p1 << std::endl;
wchar_t* p2 = L"你好世界,123456";
std::cout << p2 << std::endl;
system("pause");
}
控制台运行结果:
123456
你好世界,123456
请按任意键继续. . .