MFC -> String* to const char* or String* to char

How can I convert a String* in MFC to const char* mychar or char mychar[MAX_PATH]



Answer this question

MFC -> String* to const char* or String* to char

  • _Quimbly_

    Bigguy Graves,

    i'm pretty sure this is not the most efficient way to do this, but it's a simple way :-)

    you can simply create a mfc CString using the ctor that takes the a String*, because CStrings have build-in conversion operators for const char*.

    WM_HOPETHISHELPS
    thomas woelfer
    http://www.die.de/blog

  • BugEyeMonster

    See: Convert from System:: String* to TCHAR*/CString
    http://blog.kalmbachnet.de/ postid=18

    See: How To Convert from System:: String* to Char* in Visual C++ .NET
    http://support.microsoft.com/kb/311259/

  • kunalb

    Thank heaven for this forum! I have found the code below to help me ALOT. Now I can continue (after 2 - 3 weeks) with my project.

    //method 3
    CString str3(str);

  • MFC -> String* to const char* or String* to char