Convert Int to char[] or CString - Programmer

This is a discussion on Convert Int to char[] or CString - Programmer ; Good day I'm trying to convert an int e.g. 512 into a string that I can then display in a static control. I've tried: CString mystr = (CString)intMyInt; The above just gives me an empty string "". What would be ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Convert Int to char[] or CString

  1. Convert Int to char[] or CString

    Good day

    I'm trying to convert an int e.g. 512 into a string that I can then display
    in a static control.
    I've tried:
    CString mystr = (CString)intMyInt;
    The above just gives me an empty string "".

    What would be the correct way?
    Thanks



  2. Re: Convert Int to char[] or CString

    "Basil" wrote:

    >Good day
    >
    >I'm trying to convert an int e.g. 512 into a string that I can then display
    >in a static control.
    >I've tried:
    >CString mystr = (CString)intMyInt;
    >The above just gives me an empty string "".
    >
    >What would be the correct way?


    int myInt = 5;
    CString myStr;

    myStr.Format("%d", myInt);

    myStr now contains "5".

    --
    Tim Slattery
    Slattery_T@bls.gov

+ Reply to Thread