今天主要修改程序,并用文件存取学生数据。
void xiazai()
{FILE *fpRead=fopen("C:\\Users\\Administrator\\Desktop\\ABC.txt","r");
if(fpRead==NULL) { printf("未找到系统文件"); }
fscanf(fpRead,"%d",&kkk);
for(int i=0;i<kkk;i++)
fscanf(fpread,"%d%s%f%f%f",&p[i].xuehao,&p[i].xingming,&p[i].kemu[0],&p[i].kemu[1],&p[i].kemu[2])
fclose(fpWrite);
};
void shangchuan()
{FILE *fpWrite=fopen("C:\\Users\\Administrator\\Desktop\\ABC.txt","w");
if(fpWrite==NULL) { printf("未找到系统文件"); }
fprintf(fpWrite,"%d ",kkk); for(int i=0;i<kkk;i++)
fprintf(fpWrite,"%d %s %.2f %.2f %.2f ",(q+i)->xuehao,(q+i)->xingming,(q+i)->kemu[0],(q+i)->kemu[1],(q+i)->kemu[2]);
fclose(fpWrite);
};
网友评论