Computer Science, asked by yashika5789, 1 year ago

C program to write and read content of binary file

Answers

Answered by AnujLunawat007
0
Paste this in your c compiler


#include<stdio.h>/* Our structure */struct record  int a,b,c;};int main() int count; FILE *ptr; struct record myRecord; ptr=fopen("test.bin","rb"); if (!ptr) {     printf("Unable to open file!");     return 1; } for ( count=1; count <= 10; count++) {   fread(&myRecord,sizeof(struct record),1,ptr);   printf("%d\n",myRecord.a); }  fclose(ptr); return 0;}
Similar questions