From 01cdf0c03b58aae35f2720d101b06625a3864088 Mon Sep 17 00:00:00 2001 From: "2650279311@qq.com" <2650279311@qq.com> Date: Sat, 12 Jan 2019 20:54:55 +0800 Subject: [PATCH] first commit --- main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index e68dfbb..bfacc29 100644 --- a/main.c +++ b/main.c @@ -35,7 +35,6 @@ void Deletestudent(); //删 void yanshi(char *p); //延时函数说明 //********************************************************************************************** -int count=0; int main() { yanshi("\n\n\n\t\t**************************欢迎使用学生信息管理系统*****************\n"); @@ -143,6 +142,7 @@ void Printstudent() // { system("cls"); system("color 1A"); + int count=0; printf("\t\t*****************************************************************************************\n"); printf("\t\t|\t\t\t欢迎使用湖南工业大学学生信息管理系统\t\t\t\t|\n"); printf("\t\t*****************************************************************************************\n"); @@ -165,7 +165,7 @@ void Savestudent() // system("cls"); system("color 1B"); FILE *fp; - fp=fopen("stu.dat","wb+"); //打开文件 + fp=fopen("stu.dat","ab+"); //打开文件 if(fp==NULL) { printf("打开文件失败!\n\n"); @@ -316,7 +316,7 @@ void Readstudent() // system("cls"); system("color 0F"); FILE *fp; - fp=fopen("stu.dat","rb"); + fp=fopen("stu.dat","ab+"); if(fp==NULL) { printf("打开文件失败!\n\n"); @@ -324,11 +324,11 @@ void Readstudent() // } //读取数据 node* p=phead; //当前节点 - while(p!=NULL) + fread(&p->stu,sizeof(student),1,fp); + while(!feof(fp)) { - fread(&p->stu,sizeof(student),1,fp); printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel); - p=p->pnext; + fread(&p->stu,sizeof(student),1,fp); } fclose(fp); printf("\n\n数据读取完毕!!!\n\n"); @@ -350,7 +350,7 @@ void Deletestudent() //删 p=p->pnext; } - if(strcmp(p->stu.name,name)!=0) + if(strcmp(p->stu.name,name)==0) { if(p=phead) {