
440 Programming and Data Structures
# includ <proceas.h>
void mainO
{
FTLh fp;
atrucc bike
{
char nazzn [40];
int acvg;
float cost;
}»
struct bike a;
fp=*fopen(’"bk.txt*, "rh *);
i f tfptwiOTIJ.)
{
puts ("Cannot opaa f i l e * ) ;
cocitd) >
}
ClrecrO/
while (fread(&e,sizeof(e),lJp)Bzil)
printf ("\n %s %d %2f'^.name^.avg^.cost);,
fcloseffp);
i
Q m m L
Model Name, Average, Prize: H O N D A 80 45OOO.0O
Model Name, Average, Prize: SUZUKI 65 43000.00
Model Name, Average, Prize: Y A M A H A 55 48000.00
Explanation In the above program the records are written in the binary mode on the disk in the file
"bk . tx t". Record writing will be over af