home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_200
/
221_01
/
itoa.c
< prev
next >
Wrap
Text File
|
1979-12-31
|
512b
|
19 lines
/*
** convert n in characters in s
*/
itoa(n, s) char *s; int n; {
int sign;
char *c;
if((sign=n)<0) /* record sign */
n = -n; /* make n positive */
c=s;
do { /* generate digits in reverse order */
*s++ = n % 10 + '0'; /* get next digit */
} while ((n = n/10) > 0); /* delete it */
if(sign<0)
*s++ = '-';
*s = '\0';
reverse(c);
}