char * CSupressionDlg::stringToLPCTSTR(string sFrom)
{
_TCHAR* sBuff = new _TCHAR[sFrom.length() + 2];
int iLength = 0;
iLength = wsprintf (sBuff,sFrom.c_str ());
sBuff[iLength+1] = '/0';
return sBuff;
}
CString 转LPCTSTR: CString cStr; const char *lpctStr=(LPCTSTR)cStr; LPCTSTR转CString: LPCTSTR lpctStr; CString cStr=lpctStr;
本文介绍了在C++中如何实现CString类型与LPCTSTR类型的相互转换。通过具体的代码示例展示了从CString转换到LPCTSTR的方法,反之亦然。这对于处理Windows环境下字符串操作十分有用。


被折叠的 条评论
为什么被折叠?



