资源描述:
《学生籍贯信息管理(c语言课设)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//1.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#include"stdio.h"#include"stdlib.h"#include"conio.h"#include"string.h"/**********************建立链表******************************/structstudent{longnumber;charname[10],address[50];structstudent*nex
2、t;};/**************************文件操作函数******************************/FILE*fp;voidopenfile(charfile[20]){fp=fopen(file,"ab+");if(fp==NULL)fp=fopen(file,"wb");}/************************录入信息函数***********************************/voidstunew(void){system("cls");intn=0;longxn
3、umber;charxname[10];charxaddress[50];structstudent*head;structstudent*p1,*p2;head=NULL;p2=NULL;printf("***********欢迎使用户籍管理系统***********");printf("******录入信息******");printf("=>提示输入0返回上级菜单<=");printf("请输入学号【15字内】:");scanf("%ld",&xnumber);if(xnumber==0)
4、gotoend;printf("请输入姓名【10字内】:");scanf("%s",xname);printf("请输入籍贯【25字内】:");scanf("%s",xaddress);while(xnumber!=0){n++;p1=(structstudent*)malloc(sizeof(structstudent));p1->number=xnumber;strcpy(p1->name,xname);strcpy(p1->address,xaddress);if(n==1)head=p1;elsep2->next=
5、p1;p2=p1;printf("请输入学号【15字内】:");scanf("%ld",&xnumber);if(xnumber==0)break;printf("请输入姓名【10字内】:");scanf("%s",xname);printf("请输入籍贯【25字内】:");scanf("%s",xaddress);}p2->next=NULL;p1=head;while(p1!=NULL){openfile("E:\student.dat");chard[5]="辽宁";fwrite(p1,sizeof(struc
6、tstudent),1,fp);fclose(fp);if(strstr(p1->address,d)!=NULL){openfile("E:\lnstu.dat");fwrite(p1,sizeof(structstudent),1,fp);fclose(fp);}else{openfile("E:\qtstu.dat");fwrite(p1,sizeof(structstudent),1,fp);fclose(fp);}p1=p1->next;}end:;}/*****************************查询函
7、数*************************/voidstuxhselect(void)//按学号方式查询函数{begain:intn=0;longxh;system("cls");printf("***********欢迎使用户籍管理系统***********");printf("******查询编辑信息******");printf("=>提示输入0返回上级菜单<=");printf("请您输入学号:");scanf("%ld",&xh);if(xh!=0){structstudent*
8、p;structstudent*q=NULL,*head=NULL;fp=fopen("E:\student.dat","rb");if(fp==NULL){printf("没有记录,请输入记录然后再查询!");getch();gotoend