16 王华俊 2013.07 scanf(\ while(1) {
switch(b1) {
case 1:goto A;break; case 2:return(back=1); case 0: {
system(\ printf(\
------------------------------------------------------------\\n\
printf(\感谢使用,再见! =- \\n\
printf(\
------------------------------------------------------------\\n\ exit(0); } } } } }
int search_1(int back)//【进入图书信息查询函数(管理员版)】 {
int a,back3;
A:system(\为一个标志位,用于返回本函数首界面 back=0;back3=0; search_menu(); scanf(\ while(1) {
switch(a) {
case 1:{back3=search_number(back3);if(back3==1)goto A;}//进入编号查询
case 2:{back3=search_title(back3);if(back3==1)goto A;}//进入书名查询
2013.07 中国地质大学C语言课程设计 17 case 3:return(back=1); } } }
int search_number(int back)//【按编号查询函数(管理员版)】 {
FILE *fp;
long long int number; struct Book *p; int b1;
A:system(\为一个标志位,用于返回本函数首界面 back=0;
printf(\请输入图书编号(数字):\ scanf(\
fp=fopen(\图书信息数据库.txt\
if(fp==NULL){printf(\数据库打开错误!请检查...\\n\ p=(struct Book*)malloc(LONG); while(1) {
if(feof(fp)) {
fclose(fp);
printf(\未找到与条件相符的图书!\\n\\n\ printf(\
-------------------------------------------------------\\n\
printf(\继续搜索 [2].返回上一级菜单 [0].退出系统 \\n\
printf(\
-------------------------------------------------------\\n\ printf(\请选择:\ scanf(\ while(1) {
switch(b1) {
18 王华俊 2013.07 case 1:goto A;break; case 2:return(back=1); case 0: {
system(\ printf(\
------------------------------------------------------------\\n\
printf(\感谢使用,再见! =- \\n\
printf(\
------------------------------------------------------------\\n\ exit(0); } } } }
fscanf(fp,\or,p->press,p->year,p->claim_number,p->unit_price,&p->collection,&p->can_borrow,p->student_name,p->sex,p->student_id,&p->number); if(number==p->number) {
fclose(fp);
printf(\===================\\n\\n\
printf(\编号:\索取号:\年份:\单价:\
printf(\书名:%s\\n\\n\
printf(\作者:\出版社:\
printf(\%-6s%-12d%s%d\\n\\n\馆藏:\可借:\
printf(\借书人信息
|| %-6s%-10s%-6s%-7s%-7s%s\\n\\n\姓名:\性别:\学号:\
printf(\===================\\n\
2013.07 中国地质大学C语言课程设计 19 printf(\
-------------------------------------------------------\\n\
printf(\继续搜索 [2].返回上一级菜单 [0].退出系统 \\n\
printf(\
-------------------------------------------------------\\n\ printf(\请选择:\ scanf(\ while(1) {
switch(b1) {
case 1:goto A;break; case 2:return(back=1); case 0: {
system(\ printf(\
------------------------------------------------------------\\n\
printf(\使用,再见! =- \\n\
printf(\
------------------------------------------------------------\\n\ exit(0); } } } } } }
int search_title(int back)//【按书名查询函数(管理员版)】 {
FILE *fp;
char title[100]; struct Book *p; int a1,b1;
感谢20 王华俊 2013.07 A:system(\为一个标志位,用于返回本函数首界面 back=0; a1=0;
printf(\请输入书名:\ scanf(\
fp=fopen(\图书信息数据库.txt\
if(fp==NULL){printf(\数据库打开错误!请检查...\\n\ p=(struct Book*)malloc(LONG); while(!feof(fp)) {
fscanf(fp,\or,p->press,p->year,p->claim_number,p->unit_price,&p->collection,&p->can_borrow,p->student_name,p->sex,p->student_id,&p->number); if(strcmp(title,p->title)==0) {
a1=1;
printf(\===================\\n\\n\
printf(\编号:\索取号:\年份:\单价:\
printf(\书名:%s\\n\
printf(\作者:\出版社:\
printf(\馆藏:\可借:\
printf(\借书人信息
|| %-6s%-10s%-6s%-7s%-7s%s\\n\\n\姓名:\性别:\学号:\
printf(\===================\\n\ } } if(a1==1) {
fclose(fp); printf(\