Windows使用TCHAR,字符集为UNICODE编码

#include<windows.h>
#include <stdio.h>
#include<tchar.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(
	HINSTANCE hInstance,      // handle to current instance
	HINSTANCE hPrevInstance,  // handle to previous instance
	LPSTR lpCmdLine,          // command line
	int nCmdShow              // show state
) {
	TCHAR s[] = TEXT("保国乂民,可不敬与!");
	size_t a = _tcslen(s);
	WCHAR buf[100] = { 0 };
	wsprintfW(buf, L"字符串长度是%d", a);
	MessageBox(NULL,buf,TEXT("温馨提示"),MB_OK);
	return 0;
}



版权声明:本文为coolsunxu原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。