cstring 转string

(1)CString转换为string

 

[cpp] view plain copy
 
  1. CString cs(_T("cs"));  
  2. string s;  
  3. s = (LPCSTR)(CStringA)(cs);  



 

 

(2)string转换为CString

 

[cpp] view plain copy
 
  1. string s ="Hello World!中国";  
  2. CString cs(s.c_str());  

 

(3)string转换为LPWSTR

 

[cpp] view plain copy
 
    1. ///string ---to-----LPWSTR  
    2.   
    3.     wstring widstr;   
    4.   
    5.   std:string s("DanTeng");  
    6.   
    7.     widstr = std::wstring(s.begin(), s.end());  
    8.   
    9.     lvItem.pszText=(LPWSTR)widstr.c_str();  
posted @ 2017-10-10 16:58  xzh1993  阅读(304)  评论(0编辑  收藏  举报