主题:轉換CString
zyw222
[专家分:0] 发布于 2007-06-04 15:46:00
請問如何轉換CString為LPCSTR?
環境為VC++ 2005.
回复列表 (共2个回复)
沙发
zmaxlyxh [专家分:1210] 发布于 2007-06-18 13:13:00
MSDN有例子.我用的是Vs.net 2003
CString theString( "This is a test" );
LPTSTR lpsz = new TCHAR[theString.GetLength()+1];
_tcscpy(lpsz, theString);
板凳
zmaxlyxh [专家分:1210] 发布于 2007-06-18 13:16:00
实在不行你用个简单的。效果一样!
CString theString( "This is a test" );
LPTSTR lpsz = new char[theString.GetLength()+1];
sprintf(lpsz,"%s",(LPCTSTR)theString);
我来回复