2016-04-30 15:50:04 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
2006-11-21 13:36:25 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
** itoa(n,s) - Convert n to characters in s
|
|
|
|
*/
|
2016-04-30 15:50:04 +02:00
|
|
|
char* itoa(int n,char* s)
|
2006-11-21 13:36:25 +01:00
|
|
|
{
|
|
|
|
int sign;
|
|
|
|
char *ptr;
|
|
|
|
ptr = s;
|
|
|
|
if ((sign = n) < 0) n = -n;
|
|
|
|
do {
|
|
|
|
*ptr++ = n % 10 + '0';
|
|
|
|
} while ((n = n / 10) > 0);
|
|
|
|
if (sign < 0) *ptr++ = '-';
|
|
|
|
*ptr = '\0';
|
2016-04-30 15:50:04 +02:00
|
|
|
return strrev(s);
|
2006-11-21 13:36:25 +01:00
|
|
|
}
|
|
|
|
|