4atoi.c (309B)
1 /* Exercise 8.7 */ 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 int main(void) 7 { 8 char s[8] = { 0 }; 9 int i, total = 0; 10 11 for(i = 0; i < 4; i++) { 12 printf("Give me a string (int?): "); 13 gets(s); 14 total += atoi(s); 15 } 16 17 printf("The total is: %d\n", total); 18 19 return 0; 20 } /* E0F main */ 21