1、 /* 电话号码*/char mail30。 /* 电子邮件地址*/stuN。int k=1,n,m。 /* 定义全局变量*/void readfile()。/* 函数声明*/void seek()。void modify()。void insert()。void del()。void display()。void save()。void menu()。 int main() while(k)menu()。system(pause)。return 0。 void help()printf(n0.欢迎使用系统帮助!nn1.进入系统后,先刷新学生信息,再查询。n2.按照菜单提示键入数字代号。n3.
2、增加学生信息后,切记保存按。n4.谢谢您的使用!void readfile()/* 建立信息*/char *p=student.txt。FILE *fp。int i=0。if (fp=fopen(,r)=NULL)Open file %s error! Strike any key to exit!,p)。exit(0)。while(fscanf(fp,%s %s%d%s %s %s %s %s,stui.code,stui.name,&stui.age,stui.sex,stui.time,stui.add,stui.tel,stui.mail)=8)i+。i=i。fclose(fp)。n=
3、i。录入完毕!void seek() /*查找*/int i,item,flag。char s121。 /* 以姓名和学号最长长度+1为准*/-n-1.按学号查询-n-2.按姓名查询-n-3.退出本菜单-nwhile(1)请选择子菜单编号:scanf(%d,&item)。flag=0。switch(item)case 1:请输入要查询的学生的学号:%s,s1)。for(i=0。ii。j-)if(strcmp(stuj-1.code,stuj.code)0)strcpy(temp,stuj-1.code)。strcpy(stuj-1.code,stuj.code)。strcpy(stuj.cod
4、e,temp)。strcpy(temp,stuj-1.name)。strcpy(stuj-1.name,stuj.name)。strcpy(stuj.name,temp)。strcpy(temp,stuj-1.sex)。strcpy(stuj-1.sex,stuj.sex)。strcpy(stuj.sex,temp)。strcpy(temp,stuj-1.time)。strcpy(stuj-1.time,stuj.time)。strcpy(stuj.time,temp)。strcpy(temp,stuj-1.add)。strcpy(stuj-1.add,stuj.add)。strcpy(stu
5、j.add,temp)。strcpy(temp,stuj-1.tel)。strcpy(stuj-1.tel,stuj.tel)。strcpy(stuj.tel,temp)。strcpy(temp,stuj-1.mail)。strcpy(stuj-1.mail,stuj.mail)。strcpy(stuj.mail,temp)。 p=&stuj-1.age。 q=&stuj.age。 s=*q。 *q=*p。 *p=s。void insert() /*插入函数*/int i=n,j,flag。请输入待增加的学生数:m)。do flag=1。while(flag)请输入第%d 个学生的学号:,i+
6、1)。,stui.code)。for(j=0。jj+)if(strcmp(stui.code,stuj.code)=0)已有该学号,请检查后重新录入! /*如有重复立即退出该层循环,提高判断速度*/请输入第%d 个学生的姓名:,stui.name)。请输入第%d 个学生的年龄:stui.age)。请输入第%d 个学生的性别:,stui.sex)。请输入第%d 个学生的出生年月:(格式:年.月)n,stui.time)。请输入第%d 个学生的地址:,stui.add)。请输入第%d 个学生的电话:,stui.tel)。请输入第%d 个学生的E-mail:,stui.mail)。 i=i。whil
7、e(in+m)。n+=m。nnsort()。void del()int i,j,flag=0。char s1LEN+1。请输入要删除学生的学号:for(j=i。stuj=stuj+1。if(flag=1)删除成功,显示结果请选择菜单nn-。void display()int i。所有学生的信息为:%6s %7s %5d %5s %9s %8s %10s %14snvoid save()fp=fopen(w /*写入*/fprintf(fp,%s %s %d %s %s %s %s %snvoid menu()/* 界面*/int num。 nn 电信学生信息管理系统 nn * nn * 制作人
8、:李洋* n n*系统功能菜单* n友情提醒:查询前请先刷新系统! n - - n * n * 0.系统帮助及说明 * * 1.刷新学生信息 * n * 2.查询学生信息 * * 3.修改学生信息 * n * 4.增加学生信息 * * 5.按学号删除信息 * n * 6.显示当前信息 * * 7.保存当前学生信息* n * * n * 8.退出系统 * n * n请选择菜单编号:num)。switch(num)case 0:help()。readfile()。seek()。modify()。insert()。del()。display()。save()。k=0。版权申明本文部分内容,包括文字、
9、图片、以及设计等在网上搜集整理。版权为潘宏亮个人所有This article includes some parts, including text, pictures, and design. Copyright is Pan Hongliangs personal ownership.用户可将本文的内容或服务用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯本网站及相关权利人的合法权利。除此以外,将本文任何内容或服务用于其他用途时,须征得本人及相关权利人的书面许可,并支付报酬。Users may use the contents o
10、r services of this article for personal study, research or appreciation, and other non-commercial or non-profit purposes, but at the same time, they shall abide by the provisions of copyright law and other relevant laws, and shall not infringe upon the legitimate rights of this website and its relev
11、ant obligees. In addition, when any content or service of this article is used for other purposes, written permission and remuneration shall be obtained from the person concerned and the relevant obligee.转载或引用本文内容必须是以新闻性或资料性公共免费信息为使用目的的合理、善意引用,不得对本文内容原意进行曲解、修改,并自负版权等法律责任。Reproduction or quotation of the content of this article must be reasonable and good-faith citation for the use of news or informative public free information. It shall not misinterpret or modify the original intention of the content of this article, and shall bear legal liability such as copyright.