Reply To: convert a string to integer – atoi()

Home Forums C-programming.. convert a string to integer – atoi() Reply To: convert a string to integer – atoi()

#2129
Humble
Keymaster

If you are trying to convert the interger to string (opposite of what we discussed above) make use of sprintf() function as shown below:

$ cat str.c 
#include <stdio.h>
#include <stdlib.h>

int main()
{

char str[10];

sprintf (str,"%d", 123);

puts(str);

return 0;
}


it will return 123 as an output..