Click here to Skip to main content
15,879,326 members
Articles / Desktop Programming / MFC
Alternative
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
4.97/5 (16 votes)
7 Apr 2011CPOL 36K   13   4
CString m_Name;CT2CA pszName(m_Name);std::string m_NameStd(pszName);Works for me everywhere... :)
CString m_Name;
CT2CA pszName(m_Name);
std::string m_NameStd(pszName);

Works for me everywhere... :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionMy vote of 5! Pin
Volynsky Alex4-Nov-14 19:05
professionalVolynsky Alex4-Nov-14 19:05 
General5! Pin
Pranit Kothari13-Dec-11 1:27
Pranit Kothari13-Dec-11 1:27 
GeneralUse CT2CA (and A2W / T2A family) macros when you can. Just t... Pin
blytle13-May-11 2:02
blytle13-May-11 2:02 
GeneralReason for my vote of 5 Interesting to use the feature that ... Pin
Martin Richter [rMVP C++]19-Apr-11 2:44
Martin Richter [rMVP C++]19-Apr-11 2:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.