fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define M 200
  4.  
  5. int main()
  6. {
  7. FILE *data;
  8. int time,a[M],b[M],c[M],d[M];
  9. int i;
  10. char t[10][M];
  11. data = fopen ("data.txt","r");
  12. if ( data == NULL )
  13. {
  14. printf("Fail to open data.txt\n");
  15. exit(-1);
  16. }
  17.  
  18. time=0;
  19. while(fscanf(data,"%s %d %d %d %d",t[time],&a[time],&b[time],&c[time],&d[ti me])==5)
  20. {
  21. time++;
  22. if(time==25)break;//強制跳出
  23. }
  24. fclose(data);
  25.  
  26. for (i=0;i<=time;i++)
  27. {
  28. printf("%s %d %d %d %d\n",t[i],a[i],b[i],c[i],d[i]);
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:19:78: error: ‘ti’ undeclared (first use in this function)
     while(fscanf(data,"%s %d %d %d %d",t[time],&a[time],&b[time],&c[time],&d[ti me])==5)       
                                                                              ^
prog.c:19:78: note: each undeclared identifier is reported only once for each function it appears in
prog.c:19:81: error: expected ‘]’ before ‘me’
     while(fscanf(data,"%s %d %d %d %d",t[time],&a[time],&b[time],&c[time],&d[ti me])==5)       
                                                                                 ^
prog.c:29:5: error: expected declaration or statement at end of input
     }
     ^
prog.c:29:5: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
stdout
Standard output is empty