图书管理系统

任务背景:
18级软件工程大一上学期C语言课程设计。

编写目的:
把学习的C语言知识运用到实际上,强化能力。

任务描述:
C语言编程模拟一个简单的图书管理系统,主要包括图书的库存信息,每一本书的借阅信息以及每一个人的借书信息。

系统功能:
(1)借阅资料管理(对相关资料进行添加,删除,修改,查询等操作)
(2)借阅管理(包括借出操作,还书操作,续借处理)
(3)读者管理(定义读者借书数量和相关的借阅时间等信息)
(4)统计分析(当前借阅和相关资料状态,资料状态统计,借阅统计)

系统设计分析(程序流程图,函数模块分析):

程序源代码:
添加链接描述

/*图书管理系统   终极确定版*/ #include<stdio.h>
#include<stdlib.h>  //有system函数
#include<conio.h>   //有通过控制台进行数据输入和数据输出的函数
#include<string.h>  //有字符数组
#include<math.h>
#define  LEN   sizeof(struct library)//有关图书信息的结构体
#define  LEN1  sizeof(struct reader) //有关读者信息的结构体struct library//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%图书馆结构体
{int xcl;//库存float price;//单价char name[20],author[20],chuban[20],kind[20],shuhao[20];struct library *next;
};struct reader//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%读者结构体
{int zhenghao;char mingzi[20],riqi[20],zname[20];struct reader *next;
};void mainmenu()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~主菜单
{ system ("cls");//清除屏幕先前显示的内容 ,往下运行(在stdlib.h头文件中) printf("\n\n\n             ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ");printf("\n\n\n                     1.__库存图书信息__\n\n");printf("\n\n                       2.__借阅图书系统__\n\n");printf("\n\n                       3.__退出管理系统__\n\n");//printf("\n\n                      ^~^请您按键选择and回车确定哦~.~\n\n\n");printf("                ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ ^.^ \n");
}void menu1() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~显示 图书信息 菜单
{ system ("cls");printf("\n\n\n               ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ");printf("\n\n                          1.__图书入库__\n\n");printf("\n                       2.__图书清理__\n\n");printf("\n                       3.__图书查询__\n\n");printf("\n                       4.__库存概览__\n\n");printf("\n                       5..返回上一层..\n\n");//printf("\n                     ^~^请您按键选择and回车确定哦*.*\n\n");printf("                ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ ^~^ \n");
}void menu2() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~显示 借阅系统 菜单
{ system ("cls");printf("请输入书号,书名,作者或类别查询:\n");printf("类别(科学技术 语言文学 政治经济 历史地理 意识形态 艺术)\n\n");
}void main1()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~main1函数
{void tsgxx();//声明 图书馆信息 函数 void jieshuxitong();//声明 借书系统 函数char choose;mainmenu();//显示主菜单 scanf("%c",&choose);switch(choose)//功能函数选择{ case '1':    tsgxx();break;case '2':   jieshuxitong(); break;  case '3':   system ("cls");printf("\n\n\n  删改内容已经保存了呢 ^、^\n\n\n  任意键安全退出哦 ^、^\n\n");exit(0);//exit关闭所有文件,终止正在执行的程序。exit(0):正常退出break;}
}void tsgxx()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~图书馆信息函数
{ void tsjinku();//声明 图书进库 函数 void shanchu();//声明 删除图书信息 函数 void chaxunts();//声明 查询图书 函数 void kucunxinxi();//声明 显示库存 函数 char choose;menu1();//显示 图书信息 菜单 getchar();//吞掉一个显示出menu1函数后的进行下一步的回车      scanf("%c",&choose);for (;;)//在返回上一级前循环输入                                                                                                                                                    //??? switch(choose){ case '1':    tsjinku();break;case '2': shanchu();break;case '3': chaxunts();break;case '4':    kucunxinxi();break;case '5':  main1();//返回上一级 break;}
}int kucungs()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~统计库存图书文本个数函数
{ FILE *fp;//定义一个指针 int txcl=0,n;float tprice=0;char tname[20]={'\0'},tauthor[20]={'\0'},tchuban[20]={'\0'},tkind[20]={'\0'},tshuhao[20]={'\0'};fp=fopen("library.txt","r");//打开文件  fopen("文件名.文件类型","权限"); for (n=0;!feof(fp);n++)//逐个读文件(feof(fp):检测是否以及读取到文件尾部,到达尾部返回1,否则返回0)fscanf(fp,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);n--;fclose(fp);//关闭文件return (n);//返回个数
}int duzhegs()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~统计读者文本个数函数
{ FILE *fp;int zhenghao=0,n;char mingzi[20]={'\0'},riqi[20]={'\0'},zname[20]={'\0'};fp=fopen("reader.txt","r");//打开文件for (n=0;!feof(fp);n++)//逐个读文件fscanf(fp,"%d%s%s%s ",&zhenghao,&mingzi,&riqi,&zname);fclose(fp);//关闭文件return (n);//返回个数
}void tsjinku()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~图书进库函数
{ FILE *fp;int xcl=0,n=0;float price=0;char name[20]={'\0'},author[20]={'\0'},kind[20]={'\0'},chuban[20]={'\0'},shuhao[20]={'\0'};char hitkey; system ("cls");if ((fp=fopen("library.txt","a"))==NULL)//打开图书馆文件,不存在此文件则新建{ fp=fopen("library.txt","w");fclose(fp);}fp=fopen("library.txt","a");//追加写打开进行录入数据 printf("\n    请您输入需要添加的图书信息:\n\n  书号  书名  作者  出版社 类别  进库量 单价");printf("\n\n (类别:哲学,文学,教育,艺术,科学,教材,小说,其它)\n   (书号:(XXX) )\n"); for (;hitkey!=27;)//如果输入一组数据后敲了回车键则循环输入 { if (n!=0)printf("请输入:\n");//从第二次输入开始提示请输入 scanf("%s%s%s%s%s%d%f",shuhao,name,author,chuban,kind,&xcl,&price);        fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",shuhao,name,author,chuban,kind,xcl,price);printf("继续输入请按回车\n结束输入请按Esc\n");n++;hitkey=getch();//记录敲击进来的键                                                                                                                                                 for (;hitkey!=13&&hitkey!=27;)//13:\r回车  27:ESC退出                                                                                                                          hitkey=getch();//敲击错误可重复敲击 }fclose(fp);printf("\n保存成功,按任意键返回上一层!");getch();tsgxx();//返回上一层
}void shanchu()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~删除图书信息
{ struct library *head=NULL;struct library *p,*p1,*p2;int txcl=0,n=0,j,i;float tprice=0;char tname[20]={'\0'},tauthor[20]={'\0'},tchuban[20]={'\0'},tkind[20]={'\0'},ttname[20]={'\0'},tshuhao[20]={'\0'};char hitkey;FILE *fp;if ((fp=fopen("library.txt","r"))==NULL)//打开文件{ system ("cls");printf("\n库存图书为零!无法删除图书!\n请按任意键返回\n");getch();tsgxx();}else{ system ("cls");printf("\n请输入你要删除的书名:");//输入删除图书书名scanf("%s",&ttname);printf("\n确认删除请回车,取消请按Esc\n");hitkey=getch();for(;hitkey!=13&&hitkey!=27;)hitkey=getch();if (hitkey==27)tsgxx();fp=fopen("library.txt","r");for (j=0;!feof(fp);)//读文件夹信息,统计在库图书个数{ j++;fscanf(fp,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);}fclose(fp);fp=fopen("library.txt","r");for (i=1;i<j;i++){ fscanf(fp,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);if (strcmp(ttname,tname))//比较名字,将不同名字的信息复制到链表                                                                                     //??? { n++;//相同返回值为0不执行if语句继续循环,不同则执行直到将所有不同的书名建立成链表if (n==1)//建立链表{ p1=p2=(struct library*)malloc(LEN);head=p1;}else{ p2->next=p1;p2=p1;p1=(struct library*)malloc(LEN);//新建链表}strcpy(p1->shuhao,tshuhao);//复制书号strcpy(p1->name,tname);//复制书名strcpy(p1->author,tauthor);//复制作者名字strcpy(p1->chuban,tchuban);//复制出版社strcpy(p1->kind,tkind);//复制类别p1->xcl=txcl;//复制个数p1->price=tprice;//复制单价}}if (n==0)//如果图书只有一项且这一项刚好和要删除的相同{ head=NULL;}else//建立链表的最后剩余一个储存空间,所以封底{p2->next=p1;p1->next=NULL;fclose(fp);}}fp=fopen("library.txt","w");//清空文件,只写打开,然后关闭fclose(fp);fp=fopen("library.txt","a");//追加文件p=head;for (;p!=NULL;)//把链表内容覆盖到文件{fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",p->shuhao,p->name,p->author,p->chuban,p->kind,p->xcl,p->price);p=p->next;}fclose(fp);//关闭文件system ("cls");printf("\n删除成功 \n按任意键返回上一层\n");getch();//返回上一层tsgxx();
}void chaxunts()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~查询函数
{FILE *fp;char choose;int txcl=0,n=0,k=0,i,l;float tprice=0;char tname[20]={'\0'},tauthor[20]={'\0'},chazhao[20]={'\0'},tchuban[20]={'\0'},tshuhao[20]={'\0'},tkind[20]={'\0'};if ((fp=fopen("library.txt","r"))==NULL)//打开文件{ system ("cls");printf("\n记录文件不存在!按任意键返回");getch();tsgxx();}l=kucungs();//获得库存图书个数menu2();//提示输入菜单 scanf("%s",chazhao);system ("cls");for (i=0;i<l;i++){ fscanf(fp,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);//读文件信息if(!strcmp(chazhao,tshuhao)||!strcmp(chazhao,tname)||!strcmp(chazhao,tauthor)||!strcmp(chazhao,tkind))//在库存图书里面模糊检索 {if (k==0){printf("查询结果:\n\n");printf("书号\t书名\t作者\t\t出版社\t\t类别\t\t现存量\t单价\n");}printf("%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",tshuhao,tname,tauthor,tchuban,tkind,txcl,tprice);k++;}}if (k==0)//没有这本书 { system ("cls");printf("\n无符合记录!\n");getch();tsgxx();}fclose(fp);getch();//返回tsgxx();
}void kucunxinxi()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~显示库存图书信息
{FILE *fp;int xcl=0,n=0,i=0,j=0;float price=0;char name[20]={'\0'},author[20]={'\0'},kind[20]={'\0'},chuban[20]={'\0'},shuhao[20]={'\0'};if ((fp=fopen("library.txt","r"))==NULL)//打开文件夹{system ("cls");printf("\n记录文件不存在!");}n= kucungs();if (n==0){ system ("cls");printf("\n无任何记录!");}fp=fopen("library.txt","r");//打开只读文件system ("cls");printf("书号\t书名\t作者\t\t出版社\t\t类别\t\t库存量\t单价\n");for (i=0;i<n;i++)//输出所有在库图书信息{fscanf(fp,"%s%s%s%s%s%d%f",shuhao,name,author,chuban,kind,&xcl,&price);printf("%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",shuhao,name,author,chuban,kind,xcl,price);}fclose(fp);printf("\n按任意键返回\n");getch();//返回tsgxx();
}void menu3() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~显示借书系统主菜单
{system ("cls");printf("\n               `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` ");printf("\n\n                       1.借书登记\n\n");printf("\n\n                     2.还书登记\n\n");printf("\n\n                     3.借阅情况查看\n\n");printf("\n\n                       4.返回上一层\n\n");//printf("\n\n                  ^~^请按键选择and回车确定哦 *·*\n");printf("\n               `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~` `~`\n ");  return ;
}void jieshuxitong()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~借书系统函数
{ void jieshu();void huanshu();void duzhexinxi();//函数声明char choose;menu3();getchar();//吞掉一个显示出menu3函数后的进行下一步的回车 scanf("%c",&choose);//选择功能for (;;)switch(choose){ case '1': jieshu();break; case '2': huanshu();break;case '3': duzhexinxi();break;case '4':  main1();break;}
}void jieshu()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~借书函数
{FILE *fp,*fp3;struct library *head=NULL;struct library *p,*p1,*p2;int txcl=0,i,loop,zhenghao=0,n=0,k=0,t=0,flag=0;float tprice=0;char tname[20]={'\0'},tauthor[20]={'\0'},tchuban[20]={'\0'},tkind[20]={'\0'},tshuhao[20]={'\0'},ttname[20]={'\0'},mingzi[20]={'\0'},riqi[20]={'\0'},zname[20]={'\0'};char hitkey=0;system ("cls");{if ((fp=fopen("library.txt","r"))==NULL)//打开图书馆文件{system ("cls");printf("\n 图书馆无库存!按任意键退出!");getch();exit (0);}else{{printf("\n请输入借阅书名:\n请输入:\n");//输入书名scanf("%s",zname);k= kucungs();//统计图书馆文件个数for (i=0;i<k;i++)//读入图书馆信息,存储到链表{fscanf(fp,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);n++;if (n==1){ p1=p2=(struct library*)malloc(LEN);head=p1;}else{ p2->next=p1;p2=p1;p1=(struct library*)malloc(LEN);//新建链表}strcpy(p1->shuhao,tshuhao);//复制书号  strcpy(p1->name,tname);//复制书名strcpy(p1->author,tauthor);//复制作者strcpy(p1->chuban,tchuban);//复制出版社strcpy(p1->kind,tkind);//复制类别p1->xcl=txcl;//复制现存量p1->price=tprice;//复制单价}if (n==0)head=NULL;else{p2->next=p1;p1->next=NULL;fclose(fp);}}}p=head;for (;p!=NULL;)//读链表{if(!(strcmp(p->name,zname)))//判断要借书的是否存在{flag=1;//标记取1loop=p->xcl;//现存量减1(p->xcl)--;}p=p->next;}if(flag&&(loop>0))//存在借书书名且现存量大于0,把库存量变化后的链表存入文件{ fp=fopen("library.txt","w");fclose(fp);fp=fopen("library.txt","a");p=head;for (;p!=NULL;){fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",p->shuhao,p->name,p->author,p->chuban,p->kind,p->xcl,p->price);p=p->next;}free(p);//把链表内容覆盖文件fclose(fp);}if(flag&&(loop>0))//存在借书书名且现存量大于0{{if ((fp3=fopen("reader.txt","r"))==NULL)//建读者文件夹{ fp3=fopen("reader.txt","w");//打开只读文件fclose(fp3);            }           fp3=fopen("reader.txt","a");//以附加的方式打开文件       }{{if (n!=0)printf("\n请按以下格式输入读者信息:\n 证号 姓名 归还日期 借书书名\n请输入:");//录入读者信息scanf("%d %s %s %s",&zhenghao,&mingzi[20],&riqi[20],&zname[20]);fprintf(fp3,"\n%-8d%-23s%-18s%-10s\n",zhenghao,&mingzi[20],&riqi[20],&zname[20]);fp=fopen("library.txt","w");//删除图书馆文件信息fclose(fp);fp=fopen("library.txt","a");//重新追加信息p=head;for (;p!=NULL;)//把链表内容覆盖图书馆文件{fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",p->shuhao,p->name,p->author,p->chuban,p->kind,p->xcl,p->price);    p=p->next;}fclose(fp);fclose(fp3);printf("成功!按任意键返回\n");getch();//返回jieshuxitong();//调用借阅系统}}jieshuxitong();//调用借阅系统}elseprintf("此书已被借完!按任意键返回!");//否则输出此书已被借完getch();//返回      jieshuxitong();//调用借阅系统}
}void huanshu()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~还书函数
{FILE *fp,*fp3; struct reader *head=NULL;struct reader *p,*p1,*p2;struct library *lhead1=NULL;struct library *zp1,*lp1,*lp2;int txcl=0,i;float tprice=0;char tname[20]={'\0'},tauthor[20]={'\0'},tkind[20]={'\0'},tchuban[20]={'\0'},ttname[20]={'\0'},tshuhao[20]={'\0'};int ttzhenghao=0,tzhenghao=0,n=0,k=0,t=0,flag=0;char tmingzi[20]={'\0'},triqi[20]={'\0'},tzname[20]={'\0'},ttzname[20]={'\0'};char hitkey=0;system ("cls");{   if ((fp=fopen("reader.txt","r"))==NULL)//不存在读者文件,则输出不能还书{system ("cls");printf("\n 不存在借书者!按任意键退出!");getch();exit (0);}else{{          printf("\n请输入读者证号和书名:\n请输入:");    scanf("%d %s",&ttzhenghao,ttzname);//输入还书证号和书名k=duzhegs();//获取读者文件夹信息个数for (i=0;i<k;i++)//读取读者文件夹信息{fscanf(fp,"%d%s%s%s\n ",&tzhenghao,tmingzi,triqi,tzname);if((ttzhenghao==tzhenghao)&&!strcmp(ttzname,tzname))//如果证号书名存在,则标记为1flag=1;//strcmp:将两个字符串进行比较返回比较结果,相同返回0 }fclose(fp);fp=fopen("reader.txt","r");//打开读者文件if(flag){   for (i=0;i<k;i++)//将读者文件复制到链表{fscanf(fp,"%d%s%s%s\n ",&tzhenghao,tmingzi,triqi,tzname);//读取文件信息 if(!((ttzhenghao==tzhenghao)&&!strcmp(ttzname,tzname))){ n++;if (n==1){ p1=p2=(struct reader*)malloc(LEN1);//新建链表开辟内存 head=p1;//head指向第一个节点 }else{ p2->next=p1;p2=p1;p1=(struct reader*)malloc(LEN1);//新建链表}p1->zhenghao=tzhenghao;//复制证号strcpy(p1->mingzi,tmingzi);//复制读者名字                      strcpy(p1->riqi,triqi);//复制日期                        strcpy(p1->zname,tzname);//复制书名                  }}if (n==0)head=NULL;else{p2->next=p1;               p1->next=NULL;                  fclose(fp);             }fp=fopen("reader.txt","w");//清空读者文件fclose(fp);fp=fopen("reader.txt","a");//追加信息p=head;for (;p!=NULL;)//把链表内容覆盖读者文件         {               fprintf(fp,"\n%-8d%-23s%-18s%-10s\n",p->zhenghao,p->mingzi,p->riqi,p->zname);                     p=p->next;                  }free(p);               fclose(fp);             }}}}if(flag)//标记为1,即还书时{{{printf("确认还书请按回车!");for (;hitkey!=13&&hitkey!=27;)hitkey=getch();if (hitkey==13)printf("成功!按任意键返回!");n=0;flag=0;fp3=fopen("library.txt","r");//打开图书馆文件k=kucungs();//获取图书馆文件个数for (i=0;i<k;i++)//将图书馆文件复制到链表{                    fscanf(fp3,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);//读取信息                 n++;              if (n==1)             { lp1=lp2=(struct library*)malloc(LEN);//新建链表lhead1=lp1;}else{ lp2->next=lp1;lp2=lp1;lp1=(struct library*)malloc(LEN);//新建链表}strcpy(lp1->shuhao,tshuhao);//复制书号             strcpy(lp1->name,tname);//复制书名           strcpy(lp1->author,tauthor);//复制作者                   strcpy(lp1->chuban,tchuban);//复制出版社                  strcpy(lp1->kind,tkind);//复制类别                   lp1->xcl=txcl; //复制现存量                  lp1->price=tprice;//复制单价                    }if (n==0){lhead1=NULL;}else             {               lp2->next=lp1;              lp1->next=NULL; fclose(fp3);        }}}zp1=lhead1;     for (;zp1!=NULL;){     if(!(strcmp(zp1->name,ttzname)))//寻找书名相同         ++(zp1->xcl);//现存量加1           zp1=zp1->next;}fp3=fopen("library.txt","w");//清空图书馆文件fclose(fp);fp3=fopen("library.txt","a");//追加信息zp1=lhead1;for (;zp1!=NULL;)//把链表内容覆盖图书馆文件{fprintf(fp3,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",      zp1->shuhao,zp1->name,zp1->author,zp1->chuban,zp1->kind,zp1->xcl,zp1->price);      zp1=zp1->next;}fclose(fp3);getch();//返回jieshuxitong();//调用借阅系统}elseprintf("不存在此信息!按任意键返回!");getch();//返回jieshuxitong();//调用借阅系统
}void duzhexinxi()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~显示读者借书情况函数
{FILE *fp;int zhenghao=0,xcl=0,n=0,i=0,j=0;char mingzi[20]={'\0'},riqi[20]={'\0'},zname[20]={'\0'};if ((fp=fopen("reader.txt","r"))==NULL)//打开读者文件夹{system ("cls");printf("\n记录文件不存在!");}n=duzhegs();if (n==0){ system ("cls");printf("\n无任何记录!");}fp=fopen("reader.txt","r");system ("cls");printf("\n证号\t读者姓名\t\t还书日期\t书名\n");for (i=0;i<n;i++)//输出文件信息{   fscanf(fp,"%d%s%s%s\n ",&zhenghao,mingzi,riqi,zname); printf("\n%-8d%-23s%-18s%-10s\n", zhenghao,mingzi,riqi,zname);}fclose(fp);printf("\n按任意键返回\n");getch();//返回jieshuxitong();//调用借阅系统
}void begin()
{char num;printf("\n\n\n\n                 教师端登录请按 1 \n\n                  学生端登录请按 2 \n\n");scanf("%c",&num);getchar();
}int main()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~主函数调用
{system("color 3F");//蓝色背景白色字体 begin();main1();return 0;
}
                                                ——2018.12.28——by Z方 的 '^旧时光~'

C语言 图书管理系统(课程设计)相关推荐

  1. c语言课程设计北京电子工业出版社,c语言图书管理系统课程设计报告

    c语言图书管理系统课程设计报告 五.小节: 在这一个星期的实践中,通过编写这个图书管理系统,我体会到了c语言学习的实用性.将理论和实践结合在一起,用先进的计算机工具方便人们的生活.C语言程序的编写首先 ...

  2. c语言课程设计图书管理系统报告,C语言图书管理系统课程设计报告[1]

    C语言图书管理系统课程设计报告[1] 第三章 图书管理系统的设计与实现3.1 系统的需求分析图书登记管理系统作为一个应用软件将为学校的老师和学生提供一个对学校图书馆深入了解并借阅.还书的平台.根据系统 ...

  3. 图书馆系统c语言作业,C语言图书馆管理系统课程设计报告

    <C语言图书馆管理系统课程设计报告>由会员分享,可在线阅读,更多相关<C语言图书馆管理系统课程设计报告(16页珍藏版)>请在人人文库网上搜索. 1.高级语言程序设计课程设计报告 ...

  4. C语言课程学籍管理课程书面报告,C语言学籍管理系统课程设计报告书

    <C语言学籍管理系统课程设计报告书>由会员分享,可在线阅读,更多相关<C语言学籍管理系统课程设计报告书(30页珍藏版)>请在人人文库网上搜索. 1.C语言程序设计课程设计报告学 ...

  5. 图书借阅管理系统c语言程序设计,图书管理系统课程设计

    c语言图书管理系统附源码是一款由C语言编写的图书管理系统,它是由吾爱论坛网友分享提供的,对于学习C语言的朋友可以借鉴参考学习代码的编写,这也是在大学里初学C语言经常会遇到的课题,欢迎大家下载学习. 系 ...

  6. 基于java与sqlserver2008的班级信息管理系统源代码,图书管理系统课程设计报告(基于JAVA和SQL.Server).doc...

    可编辑版 PAGE Word完美格式 可编辑版 Word完美格式 课程设计报告 设计名称:<数据库原理与应用>课程设计 设计题目: 图书管理系统的设计与开发 学生学号: 专业班级: 学生姓 ...

  7. 物资管理系统 c语言,物资管理系统课程设计报告.doc

    物资管理系统课程设计报告 中 国 地 质 大 学 本科生课程论文封面 课程名称 c语 言 课 程 设 计课程设计评语2 目 录3 1.课程论文题目4 2.程序设计思路4 3.功能模块图5 4.数据结构 ...

  8. C语言——小型图书管理系统(课程设计)

    [文末获取资源] 该系统包括以下功能: 01.注册账号 02.登录账号 03.修改密码 04.录入功能 05.添加功能 06.删除功能 07.修改功能 08.浏览功能 09.查询密码 10.排序功能 ...

  9. c语言停车场管理系统课程设计,停车场管理系统—C语言课程设计

    <停车场管理系统-C语言课程设计>由会员分享,可在线阅读,更多相关<停车场管理系统-C语言课程设计(12页珍藏版)>请在人人文库网上搜索. 1.精品好资料学习推荐停车场管理系统 ...

  10. 图书管理系统python代码课程设计报告_数据结构图书管理系统课程设计报告

    1 一.设计题目与要求 [ 问题描述 ] 设计一个计算机管理系统完成图书管理基本业务. [ 基本要求 ] ( 1) 每种书的登记内容包括书号.书名.著作者.现存量和库存量: ( 2) 对书号建立索引表 ...

最新文章

  1. Excel导入SQL数据库完整代码
  2. 【深度学习】这才是深度学习的本源
  3. 精益与敏捷开发(随笔)
  4. 通信原理最佳接收-最佳接收准则
  5. mysql语句表_mysql表级sql语句
  6. MySQL数据库管理(二)单机环境下MySQL Cluster的安装
  7. C# 如何跨平台调用C++的函数指针!
  8. maya脚本用python还是mel_替换/替换材质的Maya Python/MEL脚本
  9. 大离谱!论文“撞衫”,11篇不同高校论文中竟出现同一块桌布....
  10. 【Java】Socket网络编程解读与实战
  11. 用c语言输出1 n平方自然数魔方阵,用C语言求:打印出由1到n平方的自然数的魔方阵...
  12. 三维点云数据处理软件供技术原理说明_三维扫描数据处理技术_点云数据处理...
  13. svnadmin hotcopy整库拷贝方式(转载)
  14. 思科路由器2811如何重设密码
  15. php 美颜,怀念以前无滤镜美颜的影视剧
  16. win10系统关闭哪些服务器,win10.1系统哪些服务可以关闭掉?
  17. android实现类似在短信图标右上角显示短信个数的效果
  18. 尚硅谷JVM下篇:性能监控与调优篇_03_JVM监控及诊断工具-GUI篇
  19. Windows10与Kali Linux之间通过XFTP来共享文件
  20. vuepress sakura漂亮的樱花插件

热门文章

  1. C语言题目:从键盘输入三个数,求三角形面积和周长
  2. 关于iWebOffice中使用变量插入到Office书签里面
  3. java od_OD使用教程
  4. 深入浅出 NXLog (二)
  5. 线性调频信号(LFM)时域与频域分析
  6. Python爬虫书籍分享
  7. 数据中心交换机芯片学习总结
  8. 【Python】9×9数独计算器
  9. Windows 中使用苹果 macOS 动态桌面壁纸
  10. 豆丁网文库下载器,版本:201…