File Handling: Read Content From a Binary File

code:

#include<stdio.h>
int main()
{
    FILE *fp;
    double data[5];

    fp=fopen("bin.bin","rb");
    if(fp==NULL){
        printf("Unable  to open file");
        return 0;
    }

    int nObjects=fread((void*)data,sizeof(double),5,fp);
    printf("Total Read: %d\n",nObjects);

    int i;
    printf("content of array:");
    for(i=0;i<5;i++)
        printf("%10.2lf",data[i]);
    fclose(fp);
    return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *