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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM