fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define SIZE 4
  5. #define STRING_SIZE 30
  6.  
  7. int main(void)
  8. {
  9. char strings[SIZE][STRING_SIZE];
  10. int total = 0;
  11.  
  12. for (int i = 0; i < SIZE; ++i)
  13. {
  14. printf("Enter integer string %d: ",
  15. i + 1);
  16.  
  17. scanf("%29s", strings[i]);
  18.  
  19. total += (int)strtol(strings[i], NULL, 10);
  20. }
  21.  
  22. printf("\nThe total is: %d\n", total);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5352KB
stdin
Standard input is empty
stdout
Enter integer string 1: Enter integer string 2: Enter integer string 3: Enter integer string 4: 
The total is: 0