2007-05-29

How to convert between 'CString' and 'std::string'? CString和std::string如何相互转换?

Q: How to convert between 'CString' and 'std::string'?

A:

'CString' to 'std::string':

Code:

CString cs("Hello" );
std::string s((LPCTSTR)cs);


'std::string' to 'CString':

Code:

std::string s("Hello" );
CString cs(s.c_str());

From : 转自: http://www.codeguru.com/forum/showthread.php?t=231155

No comments: