文档详情

图书管理系统 源代码.docx

发布:2018-12-17约1.72万字共23页下载文档
文本预览下载声明
#includestdio.h #includestring.h #includestdlib.h #includewindows.h struct adm//管理员账户 { char account[4]; char password[20]; }adm[10]; typedef struct brecord { char bname[20]; char ISBN[14]; float uprice; char writer[12]; int remain; int bd; char bsid[100][12]; }brecord; typedef struct book//书籍信息 { brecord bdata; struct book *next; }book,*bl; typedef struct srecord { char sname[14]; char gender[6]; char sid[12]; char password[20]; int sbnum; char sbn[5][20]; }srecord; typedef struct stu//学生信息 { srecord sdata; struct stu *next; }stu,*sl; char c; int scount=0,bcount=0,sflag=0; FILE *fp1,*fp2,*fp3; bl bp,bpr,bhead,bpl; sl sp,spr,shead,spl,spn; void initialization()//函数功能:初始化,将文件内容读入链表 { int i=0; brecord temp; srecord temp1; printf(欢迎使用图书馆管理系统,正在初始化。。。。。。\n); fp1=fopen(adm.txt,r); fp2=fopen(book.txt,a+); fp3=fopen(stu.txt,a+); if(fp1==NULL||fp2==NULL||fp3==NULL) { printf(打开本地文件失败!系统将自动关闭!); system(pause); exit(0); } for(i=0;i10;i++) { if(fscanf(fp1,%s%s,adm[i].account,adm[i].password)==EOF) { break; } }//将管理员账户密码读入结构体数组 adm[i] bhead=(bl)malloc(sizeof(book)); if(bhead==NULL) { printf(内存不足!系统将自动关闭!); exit(0); } bpr=bhead; while(fscanf(fp2,%s%s%f%s%d%d,temp.bname,temp.ISBN,temp.uprice,temp.writer,temp.remain,temp.bd)!=EOF) { for(i=0;itemp.bd;i++) { fscanf(fp2,%s,temp.bsid[i]); } scount++; bp=(bl)malloc(sizeof(book)); if(bp==NULL) { printf(内存不足!程序将自动关闭!); exit(0); } bp-bdata=temp;//将暂时存在temp内的内容赋到p-data里面 bpr-next=bp; bpr=bp; } bp-next=NULL;//将书籍信息存入链表 bpl=bp;//bpl存储尾结点 shead=(sl)malloc(sizeof(stu)); if(shead==NULL) { printf(内存不足!系统将自动关闭!); exit(0); } spr=shead; while(fscanf(fp3,%s%s%s%s%d,temp1.sname,temp1.gender,temp1.sid,temp1.password,temp1.sbnum)!=EOF) { for(i=0;itemp1.sbnum;i++) { fscanf(fp3,%s,temp1.sbn[i]); } scount++; sp=(sl)malloc(sizeof(stu)); if(sp==NULL) { printf(内存不足!程序将自动关闭!); exit(0); } sp-sdata=temp1;//将暂时存
显示全部
相似文档