#include <locale.h>
setlocale(LC_ALL, "");
设置下字符集就好了。
#include <locale.h>
#include <iostream>
#include "tchar.h"
using namespace std;
int main()
{
setlocale(LC_ALL, "");
TCHAR tszBuffer[20] = _T("TCHAR 字符数组");
char szBuffer[20] = "char 字符数组";
wchar_t wszBuffer[20] = L"wchar_t 字符数组";
cout << "使用Unicode字符集" << endl << endl;
wprintf(L"用wprintf显示TCHAR 字符数组:%s\n", tszBuffer);
cout << "显示char 字符数组:" << szBuffer << endl;
wprintf(L"用wprintf显示wchar_t 字符数组:%s\n", wszBuffer);
_tprintf(_T("用_tprintf显示TCHAR 字符数组:%s\n"), tszBuffer);
return 0;
}