Quote from:
http://vctipsplusplus.wordpress.com/2008/05/21/cstring-to-tchar/
CString is a very useful MFC class for string management. But, sometimes we want to convert CString data to TCHAR or something.
here is one small code snippet for performing this operation.
1
2
3 |
CString csData(_T(“”)); LPTSTR
szData = csData.GetBuffer(); csData.ReleaseBuffer(); |
or like this
1 |
CString csTemp( "Sample data"
); LPTSTR
lpszData = new
TCHAR [csTemp.GetLength()+1]; _tcscpy(lpszData , csTemp); delete [] lpszData; // don‘t forget to do this. |
原文:http://www.cnblogs.com/cindy-hu-23/p/3544455.html