Click here to Skip to main content
Click here to Skip to main content
Alternative Tip
Go to top

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

, 13 Nov 2011
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

geoyar
Software Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralYes I do: typedef std::basic_string<TCHAR> string_t. Pinmembergeoyar9-Nov-11 7:01 
Yes I do:
typedef std::basic_string string_t.
Generalstd::basic_string is template class. Did u mean: typedef std... PinmemberKaqkk799-Nov-11 3:41 
Generalstd::basic_string is template class. Did u mean: typedef std... PinmemberKaqkk799-Nov-11 3:39 
Generalstd::basic_string is template class. Did u mean: &lt;pre> ty... PinmemberKaqkk799-Nov-11 3:38 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 13 Nov 2011
Article Copyright 2011 by geoyar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid