我也是新手,胡乱写下,很多就不考虑了。你先看看:
/*
* itos.c:
* convert decimal integer to equivalent string.
*/
#include <stdio.h>
#define MAX 20
char *itos(long long int i, char s[])
{
long long int n = 0;
unsigned ind;
char snum[] = "0123456789";
for (; i > 10; i /= 10)
n = (n + i % 10) * 10;
n += i;
for (ind = 0; n != 0; ind++, n /= 10)
s[ind] = snum[n%10];
s[ind] = '\0';
return s;
}
int main(void)
{
long long int i1 = 123456789;
char s[MAX];
printf("test...\n%s\n", itos(i1,s));
return 0;
}