diff --git a/删除学生信息、查询信息.c b/删除学生信息、查询信息.c new file mode 100644 index 0000000..09128ff --- /dev/null +++ b/删除学生信息、查询信息.c @@ -0,0 +1,136 @@ +void reduce() +{ + int i=0,j,k,id; + FILE *fp1,*fp2,*ff; + ff=fopen("b.txt","r"); + fscanf(ff,"%d",&j); + close(ff); + if((fp1=fopen("a.txt","r"))==NULL) + { + printf("file open error"); + exit(0); + } + printf("ҪɾѧϢѧ\n"); + scanf("%d",&id); + while(!feof(fp1)) + { + fscanf(fp1,"%d%d%s%d%d%d%d",&student[i].id,&student[i].class,&student[i].name,&student[i].time_beginhour,&student[i].time_beginminute,&student[i].time_endhour,&student[i].time_endminute); + i++; + j=i; + } + fclose(fp1); + for(i=0;i<=j;i++) + { + if(student[i].id==id) + k=i; + } + fp2=fopen("a.txt","w"); + if(k==0) + { + for(i=1;i<=j;i++) + fprintf(fp2,"%d%d%s%d%d%d%d",student[i].id,student[i].class,student[i].name,student[i].time_beginhour,student[i].time_beginminute,student[i].time_endhour,student[i].time_endminute); + } + if(k>0) + { + for(i=0;i