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

Thread: int to CString

  1. #1
    Join Date
    Apr 1999
    Posts
    12

    int to CString

    Hi!

    do everyone know how you can change int to CString or char* to CString
    thx


  2. #2
    Join Date
    Apr 1999
    Posts
    3

    Re: int to CString

    It's very simple. The code snippet is below:
    CString myString;
    int nValue = 10;
    myString.Format("%d", nValue); //myString //contains 10 now.

    Similarly u can use %s, %c etc to format string, char to (CString similar to printf() in C)
    There is one more useful member function in CString named FormatMessage(). It is a bit difficult to use compared to format but xtremely helpful. Check it out )
    SatB


  3. #3
    Join Date
    May 1999
    Posts
    318

    Re: int to CString


    //int to CString (use Format method)
    int i=1;
    CString string;
    string.Format("%d",i);
    // Result : "1"


    // char* to CString (use operator =)
    CString string;
    char *source="try_this";
    string=(LPCSTR)source;
    // Result : "try_this";



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