Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

C++: Converting an MFC CString to a std::string

0.00/5 (No votes)
13 Nov 2011 1  
I am using CString str(_T(Test));typedef std::basic_string string_t;string_t resStr(str);It works because the CSting has a cast to LPTCSTR.
I am using

CString str(_T("Test"));
typedef std::basic_string<tchar> string_t;
string_t resStr(str);

It works because the CSting has a cast to LPTCSTR.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here