#include <string.h> #include <stdio.h> # define N 30 void save(); void open(); struct student{ char name[8]; int num; int age; float score; } stud[N]; int main( ){ int i; for (i=0;i<N;i++) scanf(&quot;%s%d%d%f&quot;,stud[i].name,&stud[i].num, &stud[i].age,&stud[i].score); save( ); printf(&quot;Press any key to show data from file\\n&quot;); getchar(); open(); return 0; } void save(){ FILE *fp; int i; if ((fp=fopen(&quot;score.dat&quot;,&quot;wb&quot;))==NULL){ printf(&quot;cannot open file\\n&quot;); return; } for (i=0;i<N;i++) if (fwrite(&stud[i],sizeof(struct student),1,fp)!=1) printf(&quot;file write error\\n&quot;); fclose(fp); } void open(){ FILE *fp; int i; if ((fp=fopen(&quot;score.dat&quot;,&quot;rb&quot;))==NULL) { printf(&quot;cannot open file\\n&quot;); return; } for (i=0;i<N;i++) if (fread(&stud[i],sizeof(struct student),1,fp)==1) printf(&quot;%-10s%8d%6d%12.2f\\n&quot;,stud[i].name,stud[i].num, stud[i].age,stud[i].score); else{ printf(&quot;file read error\\n&quot;); break; } fclose(fp); }