积极答复者
怎么输出 PWCHAR 变量的格式

问题
答案
-
你好:
首先你要修改你的机器的locale为china,在Control Pane->Region->administative->change system locale->china.
#include "stdafx.h" #include "iostream" #include "windows.h" #include <locale.h> int _tmain(int argc, _TCHAR* argv[]) { //_tsetlocale( LC_ALL, _T( "chs" ) ); setlocale( LC_ALL, "chs" ); PWCHAR p = L"WIFI信息"; std::wcout<<p<<std::endl; _tprintf(_T("WIFI信息\n")); return 0; }
运行结果如图:
Shu Hu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
可以使用WriteConsole函数直接输出到控制台:
PWCHAR p = L"WIFI 信息";
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), p, wcslen(p), NULL, NULL);Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
- 已标记为答案 _TGS 2014年12月4日 3:26
全部回复
-
你好:
首先你要修改你的机器的locale为china,在Control Pane->Region->administative->change system locale->china.
#include "stdafx.h" #include "iostream" #include "windows.h" #include <locale.h> int _tmain(int argc, _TCHAR* argv[]) { //_tsetlocale( LC_ALL, _T( "chs" ) ); setlocale( LC_ALL, "chs" ); PWCHAR p = L"WIFI信息"; std::wcout<<p<<std::endl; _tprintf(_T("WIFI信息\n")); return 0; }
运行结果如图:
Shu Hu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
可以使用WriteConsole函数直接输出到控制台:
PWCHAR p = L"WIFI 信息";
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), p, wcslen(p), NULL, NULL);Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
- 已标记为答案 _TGS 2014年12月4日 3:26