Click here to Skip to main content
13,048,406 members (123,499 online)
Click here to Skip to main content
Add your own
alternative version


Posted 1 Nov 2011

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);


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

You may also be interested in...

Comments and Discussions

Questionconvert string to Cstring? Pin
Vijay Kumbhani29-Oct-13 3:05
groupVijay Kumbhani29-Oct-13 3:05 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 1 Nov 2011
Article Copyright 2011 by Kaqkk79
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid