CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Posts
    32

    CString to char*

    Hi
    i want to convert CString to char* and vice versa.


    regards
    ram




  2. #2
    Join Date
    Jul 2001
    Location
    Germany
    Posts
    220

    Re: CString to char*

    simple sample:

    CString strString;
    char chString[256];

    strString = "Hello";
    MessageBox(NULL, strString, "CString", MB_OK);
    sprintf(chString, "%s", (LPCTSTR)strString);
    MessageBox(NULL, chString, "char String", MB_OK);
    sprintf(chString, "%s", "Hello again");
    MessageBox(NULL, chString, "char String 2", MB_OK);
    strString.Format("%s", chString);
    MessageBox(NULL, strString, "CString 2", MB_OK);




    For more, better and specific information, please refer to the Online-Help-Article "String Topics"
    (VC++ doc->using vc++->vc++ prog. guide->adding prog. functionality->details->string topics)

    "Writing a comment in your source does not necessariliy mean that your source is commented"

  3. #3
    Join Date
    Apr 2001
    Location
    Turkmenistan
    Posts
    674

    Re: CString to char*

    use LPTSTR CString::GetBuffer(n) method

    Bayram


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