c语言课程设计学生成绩管理系统(6)
时间:2026-01-18
时间:2026-01-18
c语言课程设计 c语言
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL) /*检查是否出错*/ {
printf("Cannot open this file.\n"); exit(0); }
printf("\nPLease shuru xiugai xuehao:"); scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1) {
j=atoi(data.xuehao); if(j==i) {
printf("xuehao:%s\nmingzi:%s\nnianling:%s\n",data.xuehao,data.mingzi,data.nianling);
printf("Please shuru mingzi:"); gets(data.mingzi);
printf("Please shuru shuxue score:"); gets(temp);data.score[0]=atof(temp); printf("Please input yingyu score:"); gets(temp);data.score[1]=atof(temp); printf("Please input wuli score:"); 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); }
4. 删除模块: