Mega Code Archive

 
Categories / C Tutorial / Data Type
 

The atoi() function

The atoi() function converts a string into an integer value. #include <stdio.h> #include <stdlib.h>   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.