C++ Various String Types (char, wchar_t, string, wstring, cstring)

convert char * to wchar_t *

using mbstowcs function

	char psz[] = {"helloworld\0"};
	wchar_t pwsz [10] = {0};
	int len = strlen(psz);
	int ret = mbstowcs(pwsz, psz, min(len, 10));
	cout<<ret<<endl;
	wcout<<pwsz<<endl;
Note: if the dest has less space than src, that will cause the exception. So use






原文地址:https://www.cnblogs.com/rogerroddick/p/2846714.html