CString转char *

基于Visual Studio 2010下Unicode编码的CString转char *


CString str = _T("CString to char*");
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,str,-1,NULL,NULL,0,NULL);
char *cResult = (char *)malloc(dwNum);
memset(cResult, 0, dwNum);
WideCharToMultiByte(CP_OEMCP,NULL,str,-1,c,dwNum,0,NULL);
TRACE("转换结果:%s\n",cResult);	//转换结果:CString to char*


你可能感兴趣的:(C++,mfc)