Click here to Skip to main content
11,646,594 members (76,351 online)
Click here to Skip to main content

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

, 13 Nov 2011 CPOL 4.7K
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

You may also be interested in...

Comments and Discussions

 
GeneralYes I do: typedef std::basic_string<TCHAR> string_t. Pin
geoyar9-Nov-11 7:01
membergeoyar9-Nov-11 7:01 
Generalstd::basic_string is template class. Did u mean: typedef std... Pin
Kaqkk799-Nov-11 3:41
memberKaqkk799-Nov-11 3:41 
Generalstd::basic_string is template class. Did u mean: typedef std... Pin
Kaqkk799-Nov-11 3:39
memberKaqkk799-Nov-11 3:39 
Generalstd::basic_string is template class. Did u mean: &lt;pre> ty... Pin
Kaqkk799-Nov-11 3:38
memberKaqkk799-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 | Terms of Use | Mobile
Web02 | 2.8.150731.1 | Last Updated 13 Nov 2011
Article Copyright 2011 by geoyar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid