Convert string to integer: atoi
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int i;
char str[256];
printf ("Enter a number: ");
gets ( str );
i = atoi ( str );
printf ("i = %d, its double = %d", i, i * 2 );
return 0;
}
Related examples in the same category