首页 > 其他 > 详细

Convert CString to TCHAR

时间:2014-02-11 20:43:09      阅读:272      评论:0      收藏:0      [点我收藏+]

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.

  

Convert CString to TCHAR

原文:http://www.cnblogs.com/cindy-hu-23/p/3544455.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!