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

, 1 Nov 2011
Rate this:
Please Sign up or sign in to vote.
How about this (assuming your project is set to Unicode)?CString strMyString=L"Test string";std::string strMyStdAnsiStr = CStringA(strMyString);

How about this (assuming your project is set to Unicode)?

CString strMyString=L"Test string";
std::string strMyStdAnsiStr = CStringA(strMyString);

License

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

Share

About the Author

Kaqkk79
Software Developer (Senior)
Hungary Hungary
No Biography provided

Comments and Discussions

 
Questionconvert string to Cstring? PingroupVijay Kumbhani29-Oct-13 3:05 

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.140916.1 | Last Updated 1 Nov 2011
Article Copyright 2011 by Kaqkk79
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid