Results 1 to 4 of 4

Thread: String()

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Is there a away to turn a long to a string?

    example:

    long a, b, c;
    CString strTemp;

    a = 1;
    b = 2;
    c = a + b;
    strTemp = c; (Heres the problem. This would just give me the coresponding ASCII char)

    AfxMessageBox("1 + 1 =" + strTemp,NULL,NULL);

    Any help?
    Thanks
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Assuming you've got <stdlib.h> included, this will do it I think:

    Code:
    _ltoa(c, &strTemp, 10);
    Not sure if it will work with CString, here's the prototype for it anyway:

    char *_ltoa( long value, char *string, int radix );


    Parameters

    value
    Number to be converted

    string
    String result

    radix
    Base of value
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I got that honestly about 5 seconds before my email dinged for new mail. I got it to work, thanks for your quick response though.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Oh, no problem =]
    Harry.

    "From one thing, know ten thousand things."

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