fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. char file_name[25];
  7. FILE *fp;
  8. int i=0,sum = 0,tmp,cnt = 0;
  9. int col_s[8];
  10.  
  11. fp = fopen("student.csv","r");
  12. if(fp == NULL){
  13. printf("Opening error.\n");
  14. return 1;
  15. }
  16. fscanf(fp,"%d",&tmp);
  17. while(feof(fp)){
  18. sum += tmp;
  19. cnt++;
  20. if(cnt % 838 == 0){
  21. col_s[i] = sum;
  22. sum = 0;
  23. i++;
  24. }
  25. fscanf(fp,"%d",&tmp);
  26. }
  27. printf("\n大一總人數:%d,大二總人數:%d,大三總人數:%d,大四總人數:%d\n",col_s[0]+col_s[1],col_s[2]+col_s[3],col_s[4]+col_s[5],col_s[6]+col_s[7]);
  28. fclose(fp);
  29. return 0;
  30.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:29:2: error: expected declaration or statement at end of input
  return 0;
  ^~~~~~
prog.c:6:7: warning: unused variable ‘file_name’ [-Wunused-variable]
  char file_name[25];
       ^~~~~~~~~
stdout
Standard output is empty