Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

Posted on 2012-11-08 16:05  Roger Luo  阅读(180)  评论(0编辑  收藏  举报

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