首页 > 编程语言 > 详细

c++中显示中文

时间:2020-05-21 20:01:47      阅读:58      评论:0      收藏:0      [点我收藏+]

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;
}

c++中显示中文

原文:https://www.cnblogs.com/VictorierJwr/p/12932637.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!