C语言实习:学生成绩管理系统(15)
发布时间:2021-06-07
发布时间:2021-06-07
gets(temp);data.score[2]=atof(temp);
data.score[3]=data.score[0]+data.score[1]+data.score[2];
} fwrite(&data,sizeof(data),1,fp1); }
fseek(fp,0L,0); /*将位置指针移到离头文件0个字节处*/ fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1) {
fwrite(&data,sizeof(data),1,fp); }
fclose(fp); fclose(fp1); }
void chazhao() {
if((fp=fopen("s_score.txt","rb"))==NULL) {
printf("\nCannot open this file.\n"); exit(0); }
printf("\nPLease shuru xuehao chakan:"); scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1) {
j=atoi(data.xuehao); if(i==j) {
printf("xuehao:%s mingzi:%s\n nianling:%s\n shuxue:%f\n yingyu:%f\n wuli:%f\n zongfen:%f\n",data.xuehao,data.mingzi,data.nianling,data.score[0],data.score[1],data.score[2],data.score[3]); }getch(); } }
void shanchu() {
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL) {
printf("\nopen score.txt was failed!"); getch(); exit(0);