The atoi() function converts a string into an integer value.
#include
#include
int main()
{
int age;
char years[8];
printf("Age:");
gets(years);
age=atoi(years);
printf("Age was %d years old.\n",age);
return(0);
}
Age:1
Age was 1 years old.