#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    73
    Rep Power
    12

    converting integer to a string


    hi all
    what are the functions used for converting an integer to a string?
    thanks in advance
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Dublin, Ireland
    Posts
    100
    Rep Power
    12
    i remember using itoa(integer,string,base) to do this once.
    use 10 ast the base if you're dealing with standard decimal numbers.
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    sprintf
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,143
    Rep Power
    2222
    Originally posted by fizzy
    i remember using itoa(integer,string,base) to do this once.
    use 10 ast the base if you're dealing with standard decimal numbers.
    itoa is not part of the ANSI standard and is only supported by some compilers. sprintf is a much more portable solution.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    UK
    Posts
    41
    Rep Power
    12
    Or wsprintf (if you're using windows)
    Code:
       int num = 10;
       char chstr[20];
       wsprintf(chstr, "%d", num);
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    73
    Rep Power
    12
    thanks

IMN logo majestic logo threadwatch logo seochat tools logo