65.9K
CodeProject is changing. Read more.
Home

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

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.78/5 (2 votes)

Nov 7, 2011

CPOL
viewsIcon

14897

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.