Cstring 转 char* 的正确做法

来源:互联网 发布:vb.net picturebox 编辑:程序博客网 时间:2024/06/10 01:05

在网上找了很多资料,试了很多办法,在面对有中文字符的CString时,都无能无力,在这里就不贴那些错误做法了,扰乱视听

正确的方法:

CString str;
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,str,-1,NULL,NULL,0,NULL);
char *c = new char[dwNum];
WideCharToMultiByte(CP_OEMCP,NULL,str,-1,c,dwNum,0,NULL);

来自 http://my.csdn.net/dream0411

0 0
原创粉丝点击