1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #define INT_MAX_DIGITS 5 5 6 char *itoa(int n); 7 8 int main (void) 9 { 10 char *arr; 11 arr = itoa(32211); 12 printf("%s\n", arr); 13 14 free(arr); 15 return 0; 16 } 17 18 char *itoa(int n) 19 { 20 char *arr; 21 22 arr = (char *)calloc(INT_MAX_DIGITS + 1, sizeof(char)); 23 sprintf(arr, "%d", n); 24 25 return arr; 26 }