#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0

    modifying MSVC++6.0 included header files


    stdlib.h has the function itoa(), which converts an integer into a character array - I was wondering, how would I go about finding the source code for this function so I could modify it? I would like to make it into a ftoa, float to array.

    stdlib.h includes:
    Code:
    _CRTIMP char * __cdecl _itoa(int, char *, int);
    but I can't find the source code for it - does MS hide it?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,640
    Rep Power
    4247
    There's no need to write an ftoa function. sprintf() is your friend here.
    Code:
    sprintf(buf, "%f", float_val);
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,640
    Rep Power
    4247
    Also, to answer your question about the source code for itoa(), the source for the lib functions comes with the enterprise edition IIRC (and I don't think it's installed by default either). With all other editions, you just get the compiled object code, included in the lib files. We had a discussion about how libs are built, a while ago. See Linakge of Standard Library Functions for more :).
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    Originally posted by Scorpions4ever
    There's no need to write an ftoa function. sprintf() is your friend here.
    Code:
    sprintf(buf, "%f", float_val);
    so um, at the risk of sounding stupid, how do I use that command?

    I want to convert the float value in tmpRec[iA].getCost()
    into a character array. I know that I would put my function call in the 3rd parameter, but what goes in the other 2?
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,640
    Rep Power
    4247
    Something like this:
    Code:
    char buf[100];
    
    sprintf(buf, "%f", tmpRec[iA].getCost());
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    14
    Rep Power
    0
    Thanks, you just helped me get 50 extra credit points in my class :P

IMN logo majestic logo threadwatch logo seochat tools logo