CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Jun 2001
    Location
    Switzerland
    Posts
    4,443

    C++ String: How to convert between 'CString' and 'std::string'?

    Q: How to convert between 'CString' and 'std::string'?

    A:

    'CString' to 'std::string':

    Code:
    CString cs("Hello");
    std::string s((LPCTSTR)cs);
    'std::string' to 'CString':

    Code:
    std::string s("Hello");
    CString cs(s.c_str());

    Last edited by Andreas Masur; July 24th, 2005 at 11:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured