C++: converting between string and int

Discussion in 'OT Technology' started by dinger, Mar 9, 2003.

  1. dinger

    dinger Guest

    Is there a way to convert an int to an STL string without using atoi()? Thanks.
     
  2. HardTech

    HardTech hungry

    Joined:
    May 5, 2000
    Messages:
    28,103
    Likes Received:
    1
    Location:
    NorCal
    umm.. can you use some ascii conversion function?
     
  3. Kent

    Kent Guest

    Why don't you want to use atoi?

    I don't know anything about STL, but for straight C, you could also use sprintf....

    char string[25];
    int x = 100;

    sprintf(string, "%d", x);

    Your string will now be "100" (with a null terminator)
     
  4. Dopeskills

    Dopeskills Nothing can beat the Hyundai !!!

    Joined:
    Feb 19, 2003
    Messages:
    326
    Likes Received:
    0
    Location:
    New Jersey

Share This Page