C语言 图书信息管理系统 最终源代码
更新时间:2017/2/6 12:44:00 浏览量:826 手机版
C语言 图书信息管理系统 最终源代码
#include
#include"string.h"
struct book/* book2 是用来装用户要录入图书的信息*/
{long num,time;
char name[12],writer[12],fenlei[8],danwei[10];
int pay;
}stu[100];
struct book1
{long num,time;
char name[12],writer[12],fenlei[8],danwei[10];
int pay;
}stu1[100];
struct book2/* book 是用来装cc.dat 文件中的图书信息 */
{long num,time;
char name[12],writer[12],fenlei[8],danwei[10];
int pay;
}stu2[100];
denglu()
{ char a[15]="drzhang",b[15]="29257966",c[15],d[15];
L3:
system("cls");
printf(" 欢迎登陆图书管理系统 \n\n");
printf("请输入姓名:");
gets(c);
printf("请输入密码:");
gets(d);
if(strcmp(a,c)==0&&strcmp(b,d)==0)
return 0;
else
{printf("输入错误请重新输入\n\n");
printf("1.重新输入 2.退出系统\n\n");
printf("请输入.....");
switch(getch())
{case 49: goto L3;break;
default: return 56;break;
}
}
}
/*此功能实现的是 开始菜单 的显示和具体功能的选择*/
start()
{ printf("******************************欢迎使用图
******************************"); 书管理系统
printf("* 功能目录: *");
printf("* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*");
printf("* || || *");`
printf("* || 1、图书查询 2、图书浏览 3、录入图书 4、删除与修改 5、备份与还原
|| *");
printf("* || || *");
printf("* || || *");
printf("* || || *");
printf("* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*");
printf("* 使用说明:如要选择“图书查询”,直接输入:1 退出:0
*");
printf("*************************************************************************
*******");
printf("你想要做什么:");
return getch(); /*输入选择对应功能的值,返回输入的值,即:用于判断选择的功能*/
}
/*实现备份功能,以防图书信息出错带来的麻烦,不必看懂*/
beifen()
{FILE *fp1,*fp2;
int i,a;
jieshuo();
system("cls");
printf("\n\n请选择 \\ 备份(B)| 浏览备份(L) / \\ 还原(H) / \\ 退出
(Q) / \n");
switch(getch())
{case 'B':
case 'b':
if((fp1=fopen("cc","r"))==NULL)
{printf("不能打开次文件\n");exit(0);}
if((fp2=fopen("cc01","w"))==NULL)
{printf("不能打开次文件\n");exit(0);}
fscanf(fp1,"%d",&a);
fprintf(fp2,"%d\n",a);
printf("\n\n确认备份吗?(Y/N)");
switch(getch())
{case 'Y':
case 'y':for(i=0;i
{fscanf(fp1,"%ld %s %s %s %s %ld %d",&stu[i].num,stu[i].name,stu[i].writer,stu[i].fenlei,stu[i]
.danwei,&stu[i].time,&stu[i].pay);
fprintf(fp2,"%ld\t%s\t%s\t%s\t%s\t%ld\t%d\n",stu[i].num,stu[i].name,stu[i].writer,stu[i].fenlei,st
u[i].danwei,stu[i].time,stu[i].pay);
}
printf("\n\n备份成功!\n\n是否打开浏览备份文件?(Y/N)");
switch(getch())
{case 'Y':
case 'y':fclose(fp1);fclose(fp2);liulan02();break;
case 'N':
case 'n':break;
}
break;
case 'N':
case 'n':break;
}
fclose(fp1);
fclose(fp2);
break;
case 'H':
case 'h':
if((fp1=fopen("cc01","r"))==NULL)
{printf("不能打开此文件\n");exit(0);} if((fp2=fopen("cc","w"))==NULL) {printf("不能打开此文件\n");exit(0);} fscanf(fp1,"%d",&a);fprintf(fp2,"%d\n",a); printf("\n\n确认还原吗?(Y/N)"); switch(getch()) {case 'Y': case 'y':for(i=0;i