//
void CMatManager::GetBuffer(const CString &strSource,char *pStrTemp)
{
int pathLength=strSource.GetLength();
for(int i=0; i<pathLength; i++)
{
* pStrTemp=strSource.GetAt(i);
pStrTemp++;
}
* pStrTemp='\0';
}
void test()
{
char p[256];
CString sValue;
GetBuffer(sValue,p);
}
//
void CSheet::GetBuffer(const CString &strSource,char *pStrTemp)
{
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,strSource,-1,NULL,0,NULL,FALSE);
WideCharToMultiByte (CP_OEMCP,NULL,strSource,-1,pStrTemp,dwNum,NULL,FALSE);
pStrTemp[dwNum]=0;
}
<pre name="code" class="cpp">(MBSC) 多字节
char * Topchar(const CString &strSource)
{
char* pStrTemp = new char[strSource.GetLength()] ;
#ifdef _UNICODE //Unicode
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,strSource,-1,NULL,0,NULL,FALSE);
WideCharToMultiByte (CP_OEMCP,NULL,strSource,-1,pStrTemp,dwNum,NULL,FALSE);
pStrTemp[dwNum]=0;
#elif//MBCS 工程强转
pStrTemp = (LPSTR)(LPCTSTR)strSource;
#endif
return pStrTemp;
}
【框架-MFC】CString转Char*
最新推荐文章于 2022-02-16 16:37:09 发布