#include <stdio.h>
#include <stdlib.h>

int main()
{
    int arr[10000];
    FILE * fp;
    if((fp = fopen("test","w"))==NULL){
        printf("Failed to open the file");
        exit(1);
    }
    for(int i=0; i<10000; i++){
          int rn=rand();
    fprintf(fp,"%i\n", rn);
        }
        fclose(fp);
    FILE * nf;
    if((nf = fopen("test","r"))==NULL){
        printf("Failed to open the file");
        exit(1);
    }
    if(fread(arr,sizeof(int),10000,nf)!=10000){
        if(feof(nf)) printf("File ended!");
        else printf("Error reading file");
    }
    for(int j=0;j<10000;j++)
        printf("%i\n",arr[j]);

    return 0;

}