Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

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

, 1 Nov 2011 CPOL
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);


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


About the Author

Software Developer (Senior)
Hungary Hungary
No Biography provided

Comments and Discussions

Questionconvert string to Cstring? PingroupVijay Kumbhani29-Oct-13 4: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 | Terms of Use | Mobile
Web04 | 2.8.150123.1 | Last Updated 1 Nov 2011
Article Copyright 2011 by Kaqkk79
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid