c语言课程设计—学籍管理系统

学校的课程设计,自己完成后整理了一下。
自己用链表实现的一个较简单的学籍管理系统,都是通过一些链表以及文件的基本操作完成。

功能实现

1-录入学生信息。
2-查询学生信息。
3-修改学生信息 。
4-删除学生信息。
5-显示学生信息。
6-统计信息报表。
7-读盘,存盘。

注:一些getchar()以及换行符是我为了让界面美观自己加的。

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<ctype.h>
#include<string.h>
#include<windows.h>
#define LEN sizeof(struct _stu)typedef struct _stu
{long int id;        //学号char name[20];      //姓名char sex[10];       //性别char teacher[20];   //老师int years;          //年龄char date[20];      //入学时间float score;        //入学成绩struct _stu *next;  //指向下个结点的指针
}Stu;int count = 0;//链表长度,学生总数
char choice_s;//选择void Show();//登陆界面
void Menu();//显示主菜单
Stu *Insert(Stu *pHead);//录入
Stu *Find(Stu *pHead, int id);
void Find_sum(Stu *pHead);//查询
void print(Stu *p);//显示
void Change(Stu *pHead, int id);//修改
Stu *Delete(Stu *pHead, int id);//删除
void printAll(Stu *pHead);//显示全部学生信息(总)
void printAll_1(Stu *pHead);//显示全部学生信息(姓名升序)
void printAll_2(Stu *pHead);//显示全部学生信息(成绩降序)
void data_statistics(Stu *pHead);//数据统计,打印报表
Stu *read_file(Stu *pHead);//读盘
void DeleteLink(Stu *pHead);//销毁链表
void save_file(Stu *pHead);//存盘int main()
{SetConsoleTitle("西安邮电大学学籍管理系统");     //头文件<windows.h>int i = 0;long int id;Stu *pHead = NULL;system("color 5A");                   //头文件<windows.h>,改变程序背景及字体颜色Show();pHead = read_file(pHead);while(1){Menu();switch(choice){case '1':pHead = Insert(pHead);break;case '2':Find_sum(pHead);break;case '3':printf("\n\n");printf("\t输入要修改学生学号: ");scanf("%ld",&id);Change(pHead,id);break;case '4':printf("\n\n");printf("\t输入要删除学生学号: ");scanf("%ld",&id);pHead = Delete(pHead,id);break;case '5':printAll(pHead);break;case '6':data_statistics(pHead);break;case '7':printf("\n\n");printf("\t学生总数为:%d\n",count);printf("\n");printf("\t请按任意键继续...");break;case '0':save_file(pHead);DeleteLink(pHead); //销毁链表printf("\n\n\n");printf("\t谢谢使用!\n");exit(0);}}return 0;
}void Show()    //自己添加的登陆功能,比较简单,可以自己修改添加
{int i;char passwd[18];char *ch = "WELCOME";printf("\n\n\n");printf("\t\t\t----------------------------------------------------------\n");printf("\t\t\t|                 Welcome To The System                  |\n");printf("\t\t\t----------------------------------------------------------\n");printf("\t\t\t                  用户名登陆:");do{scanf("%s",passwd);if((strcmp(passwd,"1234567")) != 0){printf("\a");//错误警示printf("\n");printf("\t\t\t                  用户名错误,请重新输入:");fflush(stdin);}}while((strcmp(passwd,"1234567")) != 0);for(i = 1; i <= 100; i++){printf("\n\n\n\n\n\n\n\n\n");printf("\t\t\t\t\t加载:%d%%",i);Sleep(9);               //头文件<windows.h>,停顿9毫秒system("cls");         //头文件<windows.h>,清屏}printf("\n\n\n\n\n\n\n\n\n");printf("\t\t\t\t\t加载完毕");Sleep(666);system("cls");printf("\n\n\n\n\n\n\n\n\n");printf("\t\t\t\t\t");for(i = 0; i < 7; i++){printf("%c",ch[i]);Sleep(333);}printf("\n\n\n");printf("\t\t\t\t\t\t\t请按任意键继续...");
}void Menu()        //主菜单
{getch();system("cls");//清屏system("color 0D");printf("\n\n");printf("\t----------------------------------------------------------\n");printf("\t|                 欢迎使用学籍管理系统                   |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   1-录入学生信息                       |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   2-查询学生信息                       |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   3-修改学生信息                       |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   4-删除学生信息                       |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   5-显示学生信息                       |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   6-统计信息报表                       |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   7-学生总数(.读盘)                    |\n");printf("\t----------------------------------------------------------\n");printf("\t|                   0-退出程序(.存盘)                    |\n");printf("\t----------------------------------------------------------\n");printf("\t请选择功能(0-7): ");fflush(stdin);scanf("%c",&choice_s);if(choice_s < '0' || choice_s > '7'){printf("\t请重新选择功能(0-7): ");scanf("%c",&choice_s);}system("cls");//清屏
}Stu *Insert(Stu *pHead)        //创建链表
{Stu *pEnd;Stu *pNew,*q;pNew = (Stu *)malloc(LEN);q = pHead;pEnd = pHead;printf("\n\n");printf("\t---------------------------------------------------------\n");printf("\t|                  ***录入学生信息***                   |\n");printf("\t---------------------------------------------------------\n");printf("\t该学生的学号为: ");scanf("%ld",&pNew->id);while(pNew->id < 0){printf("\t学号不能为负,请重新输入");scanf("%ld",&pNew->id);}while(q){if(q->id == pNew->id){printf("\t学号已存在,请重新输入: ");scanf("%ld",&pNew->id);q = pHead;continue;}q = q->next;}printf("\t学生姓名: ");scanf("%s",pNew->name);printf("\t学生性别: ");scanf("%s",pNew->sex);printf("\t学生老师: ");scanf("%s",pNew->teacher);printf("\t学生年龄: ");scanf("%d",&pNew->years);while(pNew->years < 0){printf("\t年龄不能为负,请重新输入:");scanf("%d",&pNew->years);}printf("\t学生入学时间: ");scanf("%s",pNew->date);while(strlen(pNew->date) < 8){printf("\t入学日期(年/月/日),请重新输入; ");scanf("%s",pNew->date);}printf("\t学生入学成绩: ");scanf("%f",&pNew->score);while(pNew->score < 0 || pNew->score > 750){printf("\t入学成绩(0-750),请重新输入: ");scanf("%f",&pNew->score);}pNew->next = NULL;if(pHead == NULL)pHead = pNew;else{while(pEnd && pEnd->next != NULL)pEnd = pEnd->next;pEnd->next = pNew;}count++;printf("\n");printf("\t请按任意键继续...");return pHead;
}void Find_sum(Stu *pHead)  //4种查询方式
{char choice;long int id;float score;char teacher[20];Stu *p = pHead;printf("\n\n");printf("\t---------------------------------------------------------\n");printf("\t|                  ***查询学生信息***                   |\n");printf("\t---------------------------------------------------------\n");printf("\t|                     1.按学号查询                      |\n");printf("\t---------------------------------------------------------\n");printf("\t|                     2.按成绩查询                      |\n");printf("\t---------------------------------------------------------\n");printf("\t|                     3.按老师和学号查询                |\n");printf("\t---------------------------------------------------------\n");printf("\t|                     4.按老师和成绩查询                |\n");printf("\t---------------------------------------------------------\n");printf("\t|                     0.返回主菜单                      |\n");printf("\t---------------------------------------------------------\n");printf("\t请选择查询方式: ");fflush(stdin);scanf("%c",&choice);while(choice < '0' || choice > '4'){printf("\t请重新选择功能(0-4): ");fflush(stdin);scanf("%c",&choice);}switch(choice){case '1':printf("\t输入要查询学生学号: ");scanf("%ld",&id);print(Find(pHead,id));       //调用print(),Find()函数printf("\n");printf("\t请按任意键继续...");getchar();return;case '2':printf("\t输入要查询学生成绩: ");scanf("%f",&score);while(p && p->score != score) p = p->next;if(!p){printf("\t对不起,没有查询到该学生信息.\n");}else{printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t---------------------------------------------------------\n");while(p){if(p->score == score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);p = p->next;}elsep = p->next;}}printf("\n");printf("\t请按任意键继续...");getchar();return;case '3':printf("\t输入要查询老师和其学生学号: ");scanf("%s %ld",teacher,&id);while(p && strcmp(p->teacher,teacher) != 0 && p->id != id) p = p->next;if(!p){printf("\t对不起,没有查询到该信息.\n");}else{printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t---------------------------------------------------------\n");while(p){if(strcmp(p->teacher,teacher) == 0 && p->id == id){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);p = p->next;}elsep = p->next;}}printf("\n");printf("\t请按任意键继续...");getchar();return;case '4':printf("\t输入要查询老师和其学生成绩: ");scanf("%s %f",teacher,&score);while(p && strcmp(p->teacher,teacher) != 0 && p->score != score) p = p->next;if(!p){printf("\t对不起,没有查询到该信息.\n");}else{printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t---------------------------------------------------------\n");while(p){if(strcmp(p->teacher,teacher) == 0 && p->score == score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);p = p->next;}elsep = p->next;}}printf("\n");printf("\t请按任意键继续...");getchar();return;case '0':return;}
}Stu *Find(Stu *pHead, int id)
{Stu *p = pHead;while(p && p->id != id) p = p->next;return p;
}void print(Stu *p)
{if(!p){printf("\t对不起,没有查询到该学生信息.\n");}else{printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t---------------------------------------------------------\n");getchar();printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);}
}void Change(Stu *pHead, int id)
{Stu *pNew = Find(pHead,id);       调用Find()函数Stu *q = pHead;char choice;int num;int flag = 0;if(pNew){printf("\n\n");printf("\t---------------------------------------------------------\n");printf("\t|                  ***修改学生信息***                   |\n");printf("\t---------------------------------------------------------\n");printf("\t该学生信息如下: \n");printf("\t---------------------------------------------------------\n");print(pNew);          //调用print()函数printf("\t---------------------------------------------------------\n");printf("\t1.学号\t2.姓名3.性别\t4.老师\t5.年龄\n");printf("\t6.入学时间\t7.入学成绩\t8.全部修改\t0.返回主菜单\n");printf("\t请选择修改类型: ");fflush(stdin);scanf("%c",&choice);while(choice < '0' || choice > '8'){printf("\t请重新选择功能(0-8): ");fflush(stdin);scanf("%c",&choice);}switch(choice){case '1':printf("\t请输入新的学号: ");scanf("%ld",&pNew->id);while(pNew->id < 0){printf("\t学号不能为负,请重新输入: ");scanf("%ld",&pNew->id);}num = pNew->id;while(q){if(q->id == num)flag++;q = q->next;}if(flag > 1){printf("\t学号已存在,请重新选择!\n");    //学号已存在,直接返回主菜单printf("\n");printf("\t请按任意键继续...");return;}printf("\n");printf("\t请按任意键继续...");getchar();return;case '2':printf("\t请输入新的学生姓名: ");scanf("%s",pNew->name);printf("\n");printf("\t请按任意键继续...");getchar();return;case '3':printf("\t请输入新的学生性别: ");scanf("%s",pNew->sex);printf("\n");printf("\t请按任意键继续...");getchar();return;case '4':printf("\t请输入新的学生老师: ");scanf("%s",pNew->teacher);printf("\n");printf("\t请按任意键继续...");getchar();return;case '5':printf("\t请输入新的学生年龄: ");scanf("%d",&pNew->years);while(pNew->years < 0){printf("\t年龄不能为负,请重新输入:");scanf("%d",&pNew->years);}printf("\n");printf("\t请按任意键继续...");getchar();return;case '6':printf("\t请输入新的入学时间: ");scanf("%s",pNew->date);while(strlen(pNew->date) < 8){printf("\t入学日期(年/月/日),请重新输入; ");scanf("%s",pNew->date);}printf("\n");printf("\t请按任意键继续...");getchar();return;case '7':printf("\t请输入新的入学成绩: ");scanf("%f",&pNew->score);while(pNew->score < 0 || pNew->score > 750){printf("\t入学成绩(0-750),请重新输入: ");scanf("%f",&pNew->score);}printf("\n");printf("\t请按任意键继续...");getchar();return;case '8':printf("\t学号: ");scanf("%ld",&pNew->id);while(pNew->id < 0){printf("\t学号不能为负,请重新输入: ");scanf("%ld",&pNew->id);}num = pNew->id;while(q){if(q->id == num)flag++;q = q->next;}if(flag > 1){printf("\t学号已存在,请重新选择!");printf("\n");printf("\t请按任意键继续...");return;}printf("\t学生名称: ");scanf("%s",pNew->name);printf("\t学生性别: ");scanf("%s",pNew->sex);printf("\t老师: ");scanf("%s",pNew->teacher);printf("\t年龄: ");scanf("%d",&pNew->years);while(pNew->years < 0){printf("\t年龄不能为负,请重新输入:");scanf("%d",&pNew->years);}printf("\t入学时间: ");scanf("%s",pNew->date);while(strlen(pNew->date) < 8){printf("\t入学日期(年/月/日),请重新输入; ");scanf("%s",pNew->date);}printf("\t入学成绩: ");scanf("%f",&pNew->score);while(pNew->score < 0 || pNew->score > 750){printf("\t入学成绩(0-750),请重新输入: ");scanf("%f",&pNew->score);}printf("\n");printf("\t请按任意键继续...");getchar();return;case '0':printf("\n");printf("\t请按任意键继续...");return;}}else{printf("\t对不起,没有查询到该学生信息.\n");printf("\n");printf("\t请按任意键继续...");getchar();}
}Stu *Delete(Stu *pHead, int id)
{Stu *pNew = Find(pHead,id);       //调用Find()函数Stu *pTemp,*q;char ch;pTemp = pHead;q = pTemp;if(pTemp == NULL){printf("\t暂无学生信息,请先添加!");printf("\n");printf("\t请按任意键继续...");getchar();return pHead;}if(pNew){print(pNew);printf("\t是否删除(y/n): ");scanf("%c",&ch);count--;switch(ch){case 'y':while(pTemp){if(pTemp->id == id){if(pHead == pTemp)    //特殊情况,删除头节点{pHead = pTemp->next;printf("\n");printf("\t请按任意键继续...");return pHead;}q->next = pTemp->next;free(pTemp);printf("\n");printf("\t请按任意键继续...");return pHead;}q = pTemp;pTemp = pTemp->next;}case 'n':return pHead;}}else{printf("\t对不起,没有查询到该学生信息.\n");printf("\n");printf("\t请按任意键继续...");getchar();return pHead;}
}void printAll(Stu *pHead)      //3种显示方式,通过冒泡排序
{char choice;Stu *pNew = pHead;printf("\n\n");printf("\t---------------------------------------------------------\n");printf("\t|                  ***显示学生信息***                   |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   1.按学号升序显示                    |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   2.按姓名升序显示                    |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   3.按成绩降序显示                    |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   0.返回主菜单                        |\n");printf("\t---------------------------------------------------------\n");printf("\t请选择显示方式: ");fflush(stdin);scanf("%c",&choice);while(choice < '0' || choice > '3'){printf("\t请重新选择功能(0-3): ");fflush(stdin);scanf("%c",&choice);}switch(choice){case '1':if(pNew == NULL){printf("\t对不起,无学生信息!\n");}else{   //冒泡排序Stu *p = NULL;Stu *q = NULL;Stu *r = NULL;Stu n;for(p = pHead; p; p = p->next){for(q = p->next; q; q = q->next){if(p->id > q->id){n = *p;*p = *q;*q = n;r = p->next;p->next = q->next;q->next = r;}}}printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(pNew){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",pNew->id,pNew->name,pNew->sex,pNew->teacher,pNew->years,pNew->date,pNew->score);pNew = pNew->next;}}printf("\n");printf("\t请按任意键继续...");getchar();return;case '2':printAll_1(pHead);printf("\n");printf("\t请按任意键继续...");getchar();return;case '3':printAll_2(pHead);printf("\n");printf("\t请按任意键继续...");getchar();return;case '0':return;}
}void printAll_1(Stu *pHead)
{Stu *pNew = pHead;if(pNew == NULL){printf("\t对不起,无学生信息!\n");}else{Stu *p = NULL;Stu *q = NULL;Stu *r = NULL;Stu n;for(p = pHead; p; p = p->next){for(q = p->next; q; q = q->next){if(strcmp(p->name,q->name) > 0){n = *p;*p = *q;*q = n;r = p->next;p->next = q->next;q->next = r;}}}printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(pNew){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",pNew->id,pNew->name,pNew->sex,pNew->teacher,pNew->years,pNew->date,pNew->score);pNew = pNew->next;}}
}void printAll_2(Stu *pHead)
{Stu *pNew = pHead;if(pNew == NULL){printf("\t对不起,无学生信息!\n");}else{Stu *p = NULL;Stu *q = NULL;Stu *r = NULL;Stu n;for(p = pHead; p; p = p->next){for(q = p->next; q; q = q->next){if(p->score < q->score){n = *p;*p = *q;*q = n;r = p->next;p->next = q->next;q->next = r;}}}printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(pNew){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",pNew->id,pNew->name,pNew->sex,pNew->teacher,pNew->years,pNew->date,pNew->score);pNew = pNew->next;}}
}void data_statistics(Stu *pHead)       //3种打印方式,通过多遍遍历链表
{char choice;float score;Stu *p,*q,*a,*b;p = q = a = b = pHead;printf("\n\n");printf("\t---------------------------------------------------------\n");printf("\t|                  ***统计信息报表***                   |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   1.分性别打印报表                    |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   2.分成绩打印报表                    |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   3.分性别和成绩打印报表              |\n");printf("\t---------------------------------------------------------\n");printf("\t|                   0.返回主菜单                        |\n");printf("\t---------------------------------------------------------\n");printf("\t请选择显示方式: ");fflush(stdin);scanf("%c",&choice);while(choice < '0' || choice > '3'){printf("\t请重新选择功能(0-3): ");fflush(stdin);scanf("%c",&choice);}switch(choice){case '1':printf("\t男: \n");printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(p){if(strcmp(p->sex,"男") == 0){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);p = p->next;}elsep = p->next;}printf("\n");printf("\t女: \n");printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(q){if(strcmp(q->sex,"女") == 0){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",q->id,q->name,q->sex,q->teacher,q->years,q->date,q->score);q = q->next;}elseq = q->next;}printf("\n");printf("\t请按任意键继续...");getchar();return;case '2':printf("\t你想要以多少分为分界线: ");scanf("%f",&score);printf("\t%.1f分以下: \n",score);printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(p){if(p->score < score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);p = p->next;}elsep = p->next;}printf("\n");printf("\t%.1f分及以上: \n",score);printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(q){if(q->score >= score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",q->id,q->name,q->sex,q->teacher,q->years,q->date,q->score);q = q->next;}elseq = q->next;}printf("\n");printf("\t请按任意键继续...");getchar();return;case '3':printf("\t你想要以多少分为分界线: ");scanf("%f",&score);printf("\t%.1f分及以上男生: \n",score);printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(a){if(strcmp(a->sex,"男") == 0 && a->score >= score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",a->id,a->name,a->sex,a->teacher,a->years,a->date,a->score);a = a->next;}elsea = a->next;}printf("\n");printf("\t%.1f分及以上女生: \n",score);printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(b){if(strcmp(b->sex,"女") == 0 && b->score >= score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",b->id,b->name,b->sex,b->teacher,b->years,b->date,b->score);b = b->next;}elseb = b->next;}printf("\n");printf("\t%.1f分以下男生: \n",score);printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(p){if(strcmp(p->sex,"男") == 0 && p->score < score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);p = p->next;}elsep = p->next;}printf("\n");printf("\t%.1f分以下女生: \n",score);printf("\t学号\t姓名\t性别\t老师\t年龄\t入学时间\t入学成绩\n");printf("\t-------------------------------------------------------------\n");while(q){if(strcmp(q->sex,"女") == 0 && q->score < score){printf("\t%ld\t%s\t%s\t%s\t%d\t%s\t%.1f\n",q->id,q->name,q->sex,q->teacher,q->years,q->date,q->score);q = q->next;}elseq = q->next;}printf("\n");printf("\t请按任意键继续...");getchar();return;case '0':return;}
}void DeleteLink(Stu *pHead)        //销毁链表
{Stu *q = pHead;if(pHead == NULL)return;while(pHead){q = pHead->next;free(pHead);pHead = q;}pHead = NULL;
}Stu *read_file(Stu *pHead)     //读盘,直接连接到链表
{FILE *fp;Stu *pEnd,*pNew;fp = fopen("d:\\code\\student.txt","r");     //文件名自己设置if(fp == NULL){printf("\t打开失败,按任意键退出!");getchar();}pNew = (Stu *)malloc(LEN); //分配内存while(fscanf(fp,"%ld %s %s %s %d %s %f",&pNew->id,pNew->name,pNew->sex,pNew->teacher,&pNew->years,pNew->date,&pNew->score) != EOF){count++; //记录pNew->next = NULL;if(pHead == NULL)pHead = pNew;else{pEnd = pHead;while(pEnd && pEnd->next != NULL)pEnd = pEnd->next;pEnd->next = pNew;}pNew = (Stu *)malloc(LEN); //再次分配内存}free(pNew);    //最后一次分配内存是没有用到的,要释放掉fclose(fp);getchar();return pHead;
}void save_file(Stu *pHead)     //存盘
{FILE *fp;Stu *p = pHead;fp = fopen("d:\\code\\student.txt","w");     //文件名自己设置if(fp == NULL){printf("\t打开失败,按任意键退出!");getchar();}if(p == NULL)getch();else{while(p){fprintf(fp,"%ld %s %s %s %d %s %.1f",p->id,p->name,p->sex,p->teacher,p->years,p->date,p->score);fprintf(fp,"\n");p = p->next;}printf("\n\n");printf("\t存盘成功!");}fclose(fp);
}

!@#$%^&*~

c语言—学籍管理系统相关推荐

  1. C语言课程学籍管理课程书面报告,C语言学籍管理系统课程设计报告书

    <C语言学籍管理系统课程设计报告书>由会员分享,可在线阅读,更多相关<C语言学籍管理系统课程设计报告书(30页珍藏版)>请在人人文库网上搜索. 1.C语言程序设计课程设计报告学 ...

  2. c语言用数组编写学籍管理程序,c语言学籍管理系统实验报告.docx

    c语言学籍管理系统实验报告.docx 下载提示(请认真阅读)1.请仔细阅读文档,确保文档完整性,对于不预览.不比对内容而直接下载带来的问题本站不予受理. 2.下载的文档,不会出现我们的网址水印. 3. ...

  3. c语言学籍管理系统实训作业,学籍管理系统C语言实训报告

    学籍管理系统C语言实训报告 实训报告 课程名称: C语言程序设计课设 项目名称: 学籍管理系统 学 院: 专 业: 姓 名: 学 号: 指导教师: 成 绩: 目录 1 问题提出 ........... ...

  4. c语言学籍管理系统小程序,学籍业务办理系统(开源 v2.0发布 优化代码,增加小程序端)...

    更新说明: 1.此2.0版,大幅度优化代码,增加小程序端方便使用 2.v1.0测试地址已关,请勿测试 学生在校期间避免不了要和各种证明打交道,比如学籍证明.转专业申请.休学申请.退学申请等等.此类业务 ...

  5. c语言学籍管理系统1.0,C语言学籍管理系统源代码

    #include #include #include #define true 1 struct student//声明一个结构体类型 { char name[60];//姓名 char ID[7]; ...

  6. C语言编程学生学籍登录窗口,C语言实现学生学籍管理系统

    本文实例为大家分享了C语言实现学生学籍管理系统的具体代码,供大家参考,具体内容如下 #include #include #include #include #include //*********** ...

  7. c语言学籍管理实验报告,c语言实验报告(学生学籍管理系统)

    c语言实验报告(学生学籍管理系统) (20页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 14.90 积分 实实 验验 报报 告告学学 生生 学学 籍籍 ...

  8. c语言学生学籍管理修改,C语言课设之学生学籍管理系统.doc

    C语言课设之学生学籍管理系统.doc 题目学生学籍管理系统 目录一.个人简介.二.报告摘要.三.报告目录.四.报告正文. 1.系统需求分析 2.系统总体设计 3.系统详细设计六.总结. 二.报告摘要 ...

  9. 【C语言】学籍管理系统

    学籍管理系统 功能简介 界面功能展示 具体实现的方法 1.界面 gotoxy()函数定义 2.多文件管理 分多文件管理 头文件 3.链表 数据结构 创建链表 按成绩排序查询 4. 文件存储 5. 加密 ...

最新文章

  1. jsf 自定义属性_如何在JSF中实现自定义密码强度指示器
  2. 2018大数据学习路线从入门到精通
  3. 开源合同管理系统_「物联网架构」最适合物联网的开源数据库
  4. 针对数据库连接池到DRDS连接探活的优化
  5. CLR Via C# 学习笔记(5) 静态构造函数的性能
  6. AWS EC2启动Centos实例以及设置root密码登录
  7. 玩转Excel系列-SUMIF函数实例教程
  8. c( )函数--R语言
  9. 怎么把pdf文件转换成word格式文档
  10. 汉诺塔的非递归实现(借助堆栈模拟递归)
  11. 非常规的自我实现——听陆向谦讲创业
  12. matlab 冲激偶,冲激函数符号怎么念 什么是冲激函数?
  13. matlab中删除照片_matlab中删除对象
  14. 阿里云、腾讯云、华为云、Ucloud(优刻得)、天翼云 的云服务器性能测试和价格对比
  15. 【动网论坛7.1 sp1 修改】-修改搜一搜为其他搜索的方法
  16. 什么?你项目还在用Date表示时间?
  17. Thomas-Calculus——Infinite Sequences and Series(托马斯-微积分——无穷数列和级数-无穷级数)
  18. Flutter实现一个酷炫带动画的列表型多选日历组件
  19. semilogx 多条曲线_MATLAB自学笔记(十五):二维图形绘制2
  20. c语言基础-变量(字符型)

热门文章

  1. 【矩阵论】4. 矩阵运算——张量积
  2. 收购VMware之后,WaveMaker Drop Enterprise Edition
  3. 软件测试一个星期没找到bug,一个月都没有发现bug,怎么办?
  4. 自己在“在线打字系统”完成的一次打字成绩截图记录
  5. Xsocks 反弹代理s5
  6. powerbuilder介绍
  7. 【原创】三菱FX3U-48MT/ES PLC 控制台达ASDA-B2伺服驱动器
  8. HTML-参考手册: Px、Em 换算工具
  9. 【华为OD机试真题 JAVA】欢乐的周末
  10. VuePress快速上手(默认主题)