integer to string function (itoa())

Tom Armistead toma at ozdaltx.UUCP
Tue Jul 3 13:16:57 AEST 1990


In article <22888 at boulder.Colorado.EDU>, baileyc at boulder.Colorado.EDU (BAILEY CHRISTOPHER R) writes:
> 
> Help, I need an itoa() function for use with my Sun compiler.  It seems
> as if only PC versions of C have itoa functions.  So, source code for
> an integer to string function would be very helpful.  Thanks!

I can't wait to here the flames about this one...

If you are in a hurry or not real concerned about performance, you can
use sprinf() to replace the itoa() function.

    i.e.

    char buf[10];
    int number=100;

    sprintf( buf, "%d", number );

Now buf will contain the ASCII representation of number.

Tom
-- 
-------------------------------
{uunet,smu}!sulaco!ozdaltx!toma         (Tom Armistead @ Garland, Texas)
{uunet,smu}!sulaco!ozdaltx!swsrv1!toma 



More information about the Comp.lang.c mailing list