一、
使用函數(shù)_tcscpy_s:
CString theString( "This is a test" );
int sizeOfString = (theString.GetLength() + 1);
LPTSTR lpsz = new TCHAR[ sizeOfString ];
_tcscpy_s(lpsz, sizeOfString, theString);
最后再轉(zhuǎn)換一下lpsz為const型的
LPTSTR在UNICODE環(huán)境下編譯考試,大提示是whca_t類型
二、
CString str = _T("Hello World!");
char szStr[256] = {0};
wcstombs(szStr, str, str.GetLength());
const char * p = szStr;
使用函數(shù)_tcscpy_s:
CString theString( "This is a test" );
int sizeOfString = (theString.GetLength() + 1);
LPTSTR lpsz = new TCHAR[ sizeOfString ];
_tcscpy_s(lpsz, sizeOfString, theString);
最后再轉(zhuǎn)換一下lpsz為const型的
LPTSTR在UNICODE環(huán)境下編譯考試,大提示是whca_t類型
二、
CString str = _T("Hello World!");
char szStr[256] = {0};
wcstombs(szStr, str, str.GetLength());
const char * p = szStr;