How to convert CString to std::string in Visual Studio 2005

September 1, 2008

There are many methods available. But the easiest one in VS 2005 is to use the function CStringA. See the following code snippet.

   CString CStr("This is a CString");
   std::string Str = CStringA(CStr);
CStringA is a template specialization of class CStringT.