C++技巧(寬字符的CString轉換爲constchar*)
I.
使用function _ TCS cpy _ s:
c string字符串("這是一個測試");
int size of string =(the string。GetLength() 1);
LPTSTR lpsz =新TCHAR[sizeof string];
_tcscpy_s(lpsz,sizeOfString,the string);
最後,在UNICODE環境下編譯lpsz爲const類型的
LPTSTR。大提示是whca_t type
II,
CString str = _ t(" Hello world!");
char sztr[256]= { 0 };
wcstombs(sztr,Str,str。GetLength());
const char * p = sztr;
0條評論