Itoa Function in C

Itoa Function in C


  • Write a program in C to implement your own itoa function.
  • How to convert integer to string in C programming language.

Itoa function converts an integer value(positive and negative both) to a string. here is the function prototype of itoa function:

char* itoa(int val, char* string, int base);

It converts val(integer) to a string and stores it in string(character array) and returns the same. It also take base of the number as third parameter, If we pass base 2 then itoa will convert passed integer to equivalent binary number and stores it in string.

For Example:

 "1234" = itoa(1234, string, 10);
 "-1234" = itoa(-1234. string. 10);
"10011010010" = itoa("1234", string, 2);