Convert integer to string (non-standard function)
char * itoa ( int value, char * str, int base );
This function has the following parameter.
A pointer to the resulting null-terminated string, same as parameter str.
#include <stdio.h>
#include <stdlib.h>
//from w ww . j a va 2 s. c om
int main (){
int i;
char buffer [33];
printf ("Enter a number: ");
scanf ("%d",&i);
itoa (i,buffer,10);
printf ("decimal: %s\n",buffer);
itoa (i,buffer,16);
printf ("hexadecimal: %s\n",buffer);
itoa (i,buffer,2);
printf ("binary: %s\n",buffer);
return 0;
}
The code above generates the following result.