c++中显示中文

C++中显示中文问题

#include <iostream>
#include <clocale>//必须包含下面三个头文件
#include <cwchar>
#include <cstdlib>
using namespace std;

int main()
{
	wchar_t c[] = {L'你', L'好', L'中', L'国', L'欢', L'迎', L'你' };//使用宽字符型设置中文字符
                                                                        //L 表示当前为宽字符

	setlocale(LC_ALL, "chs");//设置语言为中文 头文件#include<locale.h>
	for (int i = 0; i < 7; i++)
	{
		wprintf(L"%lc", c[i]);//使用宽字符型输出函数wprintf
	}
	cout << endl;
	system("pause");
	return 0;
}
posted @ 2020-05-21 18:47  RabbitJwr  阅读(1558)  评论(0编辑  收藏  举报