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();  
原文地址:https://www.cnblogs.com/xzh1993/p/7646597.html