C function- Convert integer to string (non-standard function)
/* itoa example
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa.html*/
#include
#include
#include
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,8);
printf ("Octal: %s\n",buffer);
itoa (i,buffer,2);
printf ("binary: %s\n",buffer);
getch();
return 0;
}
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa.html*/
#include
#include
#include
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,8);
printf ("Octal: %s\n",buffer);
itoa (i,buffer,2);
printf ("binary: %s\n",buffer);
getch();
return 0;
}
留言