c语言编写学生管理系统的代码

c语言编写学生管理系统的代码

ID:19499501

大小:15.12 KB

页数:8页

时间:2018-10-02

c语言编写学生管理系统的代码_第1页
c语言编写学生管理系统的代码_第2页
c语言编写学生管理系统的代码_第3页
c语言编写学生管理系统的代码_第4页
c语言编写学生管理系统的代码_第5页
资源描述:

《c语言编写学生管理系统的代码》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、#include#include#include#include#includestructstudent{charnumber[21];charname[21];intage;charsex[3];charbirthday[8];}studentArray[100];typedefstructstudentstudent;studentstudentArray[100];charputout[5][12]={"学号","姓名","年龄","性别","出生年月"};//为格式

2、化输出做准备intcount=0;//函数声明部分voidexplain();voidreadfile();voidsearchStudent();voidmodifyStudent();voidaddStudent();voiddelStudent();voidprintAllstudent();voidsave();voidquit();voidinitial();voidinitial(){FILE*fp;charchoice='y';inti=0;fp=fopen("e:\students.txt","r");if(!fp){printf("创建文件失败,即

3、将返回");return;}for(;fread(&studentArray[i],sizeof(structstudent),1,fp)!=0;i++);count=i;}//0、说明模块voidexplain(){printf("很高兴能为您服务");printf("1.进入本系统,请先刷新学生信息,再查训");printf("2.您可以根据自己需要的信息键入菜单上的编号");printf("3.修改学生信息后记得退出前保存信息,以免信息流失");printf("4.在各个子菜单里按提示操作");printf("5.

4、谢谢您的使用及支持");}//1、刷新模块voidreadfile(){char*p="students.txt";FILE*fp;inti=0;if((fp=fopen("students.txt","r"))==NULL){printf("打开文件%s出错!请按按任意键返回",p);system("pause");return;}while(fscanf(fp,"%s%s%d%s%s",&studentArray[i].number,&studentArray[i].name,&studentArray[i].age,&studentArray[i].sex,

5、&studentArray[i].birthday)==5){i++;i=i;}fclose(fp);printf("刷新完毕。");}//2、查询模块voidsearchStudent(){inti;intjb;FILE*fp;charstudentNumber[21];charstudentName[21];intflag=0;fp=fopen("e:\students.txt","rb");if(count==0){printf("文件中还没有学生记录,请继续其他操作");return;}printf("1.按学号查询");printf("2.

6、按姓名查询");printf("3.不查询,退出");while(1){printf("请选择子菜单编号:");scanf("%d",&jb);flag=0;switch(jb){case1:printf("请输入要查询的学生的学号:");scanf("%s",&studentNumber);for(i=0;i<=count;i++){if(strcmp(studentNumber,studentArray[i].number)==0){flag=1;printf("要查找的学生相关信息如下:");printf("学号姓名年龄性别出生年月");pr

7、intf("%s%8s%7d%4s%8s",studentArray[i].number,studentArray[i].name,studentArray[i].age,studentArray[i].sex,studentArray[i].birthday);printf("");printf("");}}if(flag==0){printf("没有找到学号为%s的学生",studentNumber);printf("");return;}return;case2:printf("请输入要查询的学生的姓名:");fflus

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。