fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int arr[10000];
  7. FILE * fp;
  8. if((fp = fopen("test","w"))==NULL){
  9. printf("Failed to open the file");
  10. exit(1);
  11. }
  12. for(int i=0; i<10000; i++){
  13. int rn=rand();
  14. fprintf(fp,"%i\n", rn);
  15. }
  16. fclose(fp);
  17. FILE * nf;
  18. if((nf = fopen("test","r"))==NULL){
  19. printf("Failed to open the file");
  20. exit(1);
  21. }
  22. if(fread(arr,sizeof(int),10000,nf)!=10000){
  23. if(feof(nf)) printf("File ended!");
  24. else printf("Error reading file");
  25. }
  26. for(int j=0;j<10000;j++)
  27. printf("%i\n",arr[j]);
  28.  
  29. return 0;
  30.  
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:12:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for(int i=0; i<10000; i++){
     ^
prog.c:12:5: note: use option -std=c99 or -std=gnu99 to compile your code
prog.c:26:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for(int j=0;j<10000;j++)
     ^
stdout
Standard output is empty