VS2005中,如何把CString 转成 char * ,
用str.GetBuffer(str.GetLength());
和 char * p = (LPSTR)(LPCTSTR)str;
貌似都不行,同样两种方法在VC6中都可以用,小弟头一次用VS
用str.GetBuffer(str.GetLength());
和 char * p = (LPSTR)(LPCTSTR)str;
貌似都不行,同样两种方法在VC6中都可以用,小弟头一次用VS
strTemp.GetBuffer(strTemp.GetLength());
USES_CONVERSION;
char* szText = T2A(strText);
USES_CONVERSION;
char* szText = W2A(strText.GetBuffer(0));
这样就可以了,其中m_UsbKeyId是CString对象。
CString str(_T("Good Morning"));
p = str.GetBuffer(str.GetLength());
不知道行不行,我也没有用过VS2005,不过可以试一下
WideCharToMultiByte(...)
str.operator LPCTSTR(); //返回值就是char数组
//#include <atlconv.h>USES_CONVERSION;
CString str = _T("abdefg");
std::string strConv = (char *)W2A(LPCTSTR(str));
USES_CONVERSION;
char* szText = T2A(strText);这个真可以转换