资源描述:
《c语言 学生成绩信息管理系统 c语言》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//last#include#include#include#include#defineHEADER1"--------------------------STUDENT----------------------------"#defineHEADER2"
2、number
3、name
4、sex
5、"#defineHEADER3"
6、--------
7、--------
8、--------
9、"#defineFORMAT"姓名:%-6s性别:%-6s学号
10、:%-6s"#defineEND"-------------------------------------------------------------"#defineDATAtemp.Name,temp.Num,temp.Sextypedefstruct_Student{charName[12];charSex[4];charNum[20];}Student;voidMenu(FILE*);voidLuRu(FILE*);voidSeekStudent(FILE*);voidQingKong(FILE*);voidJ
11、iaMi(char*,int);voidJieMi(char*,int);voidDelete(FILE*);voidUpDate(FILE*);voidJudgeFP(FILE*);intFileSize(FILE*);voidDisPlay(FILE*fp);intmain(){FILE*fp;intchoice;fp=fopen("student.txt","ab+");JudgeFP(fp);fp=fopen("student.txt","rb+");JudgeFP(fp);if(fp==NULL){printf("ERROR
12、!");exit(0);}while(1){system("cls");Menu(fp);scanf("%d",&choice);switch(choice){case0:break;case1:LuRu(fp);break;case2:SeekStudent(fp);break;case3:QingKong(fp);break;case4:Delete(fp);break;case5:UpDate(fp);break;case6:DisPlay(fp);break;default:printf("输入错误");}if(cho
13、ice==0)break;printf("任意键返回主菜单");getch();fflush(stdin);}fclose(fp);return0;}voidLuRu(FILE*fp)//录入{Studenttemp;charch;do{printf("姓名:");scanf("%s",temp.Name);printf("性别:");scanf("%s",temp.Sex);printf("编号:");scanf("%s",temp.Num);fseek(fp,0L,SEEK_END);//JiaMi((char*)&temp,si
14、zeof(Student));fwrite(&temp,sizeof(Student),1,fp);printf("任意键继续录入0跳出");fflush(stdin);}while((ch=getch())!='0');}voidQingKong(FILE*fp)//清空数据{if((fp=fopen("student.txt","wb"))==NULL){printf("ERROR!");return;}printf("数据已清空");}voidSeekStudent(FILE*fp)//查询{Studenttemp;
15、charin[20];inti=0,j;printf("输入姓名或者学号查询:");scanf("%s",in);rewind(fp);for(j=0;j16、
17、strcmp(in,t
18、emp.Num)==0){printf(FORMAT,DATA);i=1;}}if(i==0)printf("没找到");}voidDelete(FILE*fp)//删除{Studenttemp,del;Studen