Home › Forums › C-programming.. › convert a string to integer – atoi() › Reply To: convert a string to integer – atoi()
January 14, 2014 at 12:33 pm
#2129
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..