CString->TCHAR*的转化可以用函数GetBuff()
函数原型为:LPTSTR GetBuffer( int nMinBufLength );
CString str("CString");
TCHAR* szMsg = new TCHAR[100];
//其参数为CString字符串的长度
szMsg = str.GetBuffer(str.GetLength());
str.ReleaseBuffer();
delete []szMsg;
szMsg = NULL;
TCHAR*->CString的转化
TCHAR szTchar[18] = L"TCHAR";
CString str;
str.Format(_T("%s"),szTchar);
本文介绍了在C++中如何实现CString对象与TCHAR*指针之间的相互转换方法。利用CString的GetBuffer()函数可以将CString转换为TCHAR*,而通过TCHAR数组结合CString的Format方法可以实现相反的转换。
6万+

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



