首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

unicode下CString转const char*的方法?解决方案

2012-03-05 
unicode下CString转const char*的方法?我的vc工程在unicode环境下,请问如何将CString转为const char*呢?多

unicode下CString转const char*的方法?
我的vc工程在unicode环境下,请问如何将CString转为const char*呢?
多谢了!

[解决办法]
wcstombs
[解决办法]
CString str(_T("中国abc"));
int nLen = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
if(nLen > 0)
{
char* pBuf = new char[nLen];
WideCharToMultiByte(CP_ACP, 0, str, -1, pBuf, nLen, NULL, NULL);
delete []pBuf;
}

热点排行