#include <stdio.h>
int _strlen(char *s) {
int i = 0;
while (s[i++] != '\0');
return i - 1;
}
void _reverse(char *s) {
int i = 0, end = _strlen(s) - 1, temp;
while (i < end) {
temp = s[i];
s[i] = s[end];
s[end] = temp;
i++; end--;
}
}
void _inttostr(int n, char s[]) {
int i = 0;
while (n) {
s[i++] = (n % 10) + '0';
n = n / 10;
}
_reverse(s);
s[i] = '\0';
}
int main(int argc, char **argv)
{
char s[10] = "";
int n = 9784;
_inttostr(n, s);
printf("%s\n", s);
return 0;
}
/*
run:
9784
*/