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;
}
Yesterday is history,tomorrow ismystery,but today is a gift!That why it is called Present!
原文地址:https://www.cnblogs.com/VictorierJwr/p/12932637.html