哪位大虾帮忙修改下啊!急用!
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
#include <process.h>
struct date //日期
{
int month;
int day;
int year;
};
struct BookList //图书结构体
{
char name[20]; //书名
char sort; //图书分类号
char editor[20]; //主编
char publisher[20]; //出版社
char theme[20]; //主题词
int edition; //版次
struct date publish; //出版日期
int ISBN; //ISBN
float price; //定价
int user_number; //借阅人借阅证号
struct date lend; //借阅日期
int booking_number; //借阅预约人借阅证号
char borrowname[20];//借阅人用户名
char ordername[20];//预约人用户名
struct date booking; //预约日期
int okay;//遗损情况:1,完好;2,损坏;3,遗失 //损毁情况
int yes;//判断书是否已经被借出或预约:0,已被预约;1,可借出或预约;2,已被预约
}Book[1000];;
struct StudentList //用户//日期
{
char name[20];//用户名
char password[16];//密码
}Student[1000];
void mainpage();//主页面
void MemberAdd();//旧用户登录
void landing(); //旧用户登录
void administrators();//管理员登录
void second();//成功登录后的界面
void change(); //修改密码
void BookBorrow();//借阅图书
void BookSearch();//查找图书信息
void Booking();//预约图书
void BookReturn();//归还图书
void Bookleft();//遗损处理
void AddBooks();//新书入库
void AllBooks();//登记
void MemberBook();//会员登记
main() //主函数
{
printf("********************************************************************************\n");
printf("********************************************************************************\n");
printf("******* *******\n");
printf("******* 欢迎使用图书管理系统 *******\n");
printf("******* *******\n");
printf("********************************************************************************\n");
printf("********************************************************************************\n");
printf("\n按数字键选择您所需的服务:\n");
printf("1.新用户注册\n");
printf("2.旧用户登录\n");
printf("3.管理员登录\n");
printf("\n");
mainpage();
}
void mainpage() //主页面
{
int order1;
scanf("%d",&order1);
switch(order1)
{
case 1: MemberAdd();break;
case 2: {landing();}break;
case 3: administrators();break;
default: {printf("\n你输入了错误的命令号!请你再次输入\n\n");main();mainpage();}
}
}
void MemberAdd() //新用户注册
{
FILE *fp;
char newpass[14];
int i,temp;
printf("请输入你要注册的用户名!\n");
printf("(帐号必需用18位以内的数字组成)\n");
scanf("%s",&Student->name);
if((fp=fopen(Student->name,"r"))!=NULL)
{printf("该用户名已被注册,请你用另一个用户名!\n");MemberAdd();}
else
{
for(temp=0;temp==0;)
{
printf("\n请输入你的密码!\n");
i=0;
while((Student->password[i]=getch())!='\r'&&i<=14)//变星号输出
{
if(Student->password[i]=='\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
putchar('*');
i++;
}
}
Student->password[i]='\0';
printf("\n请再次你输入你的密码!\n");
i=0;
while((newpass[i]=getch())!= '\r'&&i<=14)//变星号输出
{
if(newpass[i]=='\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
putchar('*');
i++;
}
}
newpass[i]='\0';
if(strcmp(Student->password,newpass)!=0)
printf("\n你的两个密码不一样,请重新输入\n");
else
temp=1;
}
if((fp=fopen(Student->name,"w"))==NULL)
{
printf("不能打开文件!");
return;
}
else if(fwrite(&Student,sizeof(struct StudentList),1,fp)!=1)
{
printf("数据保存错误!");
fclose(fp);
}
else
{
printf("\n你已成功注册了一个帐号,请你记住你的帐号与密码!\n");
printf("你的帐号是: %s\n请你记住你的帐号与密码!\n\n\n\n\n\n",Student->name);
second();
}
}
}
void landing() //旧用户登录
{
FILE *fp;
char acc[18],pw[14];
int i;
printf("请输入你的帐号!\n");
scanf("%s",acc);
if((fp=fopen(acc,"r"))==NULL) //检验帐号是否存在
{
printf("没有这个帐号!请先注册!");
main();
mainpage();
}
printf("请输入你的密码!\n");
i=0;
while((pw[i]=getch())!= '\r'&&i<=14)
{
if(pw[i]=='\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
putchar('*');
i++;
}
}
pw[i]='\0';
fread(&Student,sizeof(struct StudentList),1,fp);
if(strcmp(pw,Student->password)!=0)
{
printf("密码错误!\n");
main();
mainpage();
}
else
{
printf("\n你已经成功进入了管理系统!\n");
fclose(fp);
second();
}
}
void administrators()//管理员登录
{
second();
}
void second()//成功登录后的界面
{
char j;
int i,leap=0;
printf("********************************************************************************\n");
printf("********************************************************************************\n");
printf("******* *******\n");
printf("******* 欢迎进入华南农业大学图书馆 *******\n");
printf("******* *******\n");
printf("********************************************************************************\n");
printf("********************************************************************************\n");
printf("\n按数字键选择您所需的服务:");
printf("\n@ 1:修改密码\n@ 2:借阅图书\n@ 3:预约图书\n@ 4: 归还图书\n@ 5: 查图书\n@ 6: 所有图书\n@ 7: 新书入库\n@ 8:退出\n\n");
printf("\n您的选择是:");
scanf("%c",&j);
(int)i=j;
do
{
switch(i)
{
case 1:printf("\n");change();break;
case 2:printf("\n");BookBorrow();break;
case 3:printf("\n");Booking();break;
case 4:printf("\n");MemberBook();break;
case 5:printf("\n");BookSearch();break;
case 6:printf("\n"); AllBooks();break;
case 7:printf("\n"); AddBooks();break;
case 8:printf("\n");break;
default:scanf("%d",&i);leap=1;
}
}while(leap==1);
}
void change() //修改密码
{
FILE *fp;
char newpw[14],oldpw[14],newpw2[14];
int i;
printf("请你输入你的旧密码!\n");
i=0;
while((oldpw[i]=getch())!= '\r'&&i<=14)
{
if(oldpw[i]=='\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
putchar('*');
i++;
}
}
oldpw[i]='\0';
printf("\n请你输入你的新密码!\n");
i=0;
while((newpw[i]=getch())!= '\r'&&i<=14)
{
if(newpw[i]=='\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
putchar('*');
i++;
}
}
newpw[i]='\0';
printf("\n请再次你输入你的新密码!\n");
i=0;
while((newpw2[i]=getch())!= '\r'&&i<=14)
{
if(newpw2[i]=='\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
putchar('*');
i++;
}
}
newpw2[i]='\0';
fp=fopen(Student->name,"r");
fread(&Student,sizeof(struct StudentList),1,fp);
if(strcmp(oldpw,Student->password)==0)
{
if(strcmp(newpw,newpw2)!=0)
{
printf("你的两个新密码不一样,请重新输入\n");
change();
}
strcpy(Student->password,newpw);
fclose(fp);
if((fp=fopen(Student->name,"w"))==NULL)
{
printf("不能打开文件!");
return;
}
else if(fwrite(&Student,sizeof(struct StudentList),1,fp)!=1)
{
printf("数据保存错误!");
fclose(fp);
}
printf("你的密码已经修改,下次登录请使用新密码!\n\n\n");
second();
}
else
{
printf("旧密码不正确,请重新输入\n\n");
second();
}
}
void BookBorrow()//借阅图书
{
FILE *fp;
// time_t am;//测试
char bookname[40];
int i,j,w,flag=0;
if((fp=fopen("books_list.txt","rb"))==NULL)
{
printf("\n无法打开该文件! ");
return;
}
else
for(w=0;w<1000;w++)
{fread(&Book[w],sizeof(struct BookList),1,fp);}
fclose(fp);
printf(" 借书\n");
printf("\n请输入图书名:");
scanf("%s",bookname);
//getchar();
for(i=0;i<1000;i++)
{
if((strcmp(Book[i].name,bookname))==0)
{ //printf("ghdfghdfsg");
flag=1;
if(Book[i].okay==1)
{
if(Book[i].yes==1)
{
strcpy(Book[i].borrowname,Student->name);
Book[i].yes=0;
fp=fopen("books_list.txt","wb");
for(j=0;j<1000;j++)
fwrite(&Book[j],sizeof(struct BookList),1,fp);
fclose(fp);
printf("\n借书成功!\n*为了其他用户也能即使借阅这本书,请您于一个月内归还此书。多谢合作!*\n");
second();
}
else
{
printf("\n该书已被借出或已被预约\n");
second();
}
}
else
{
printf("该书已遗损!\n");
second();
}
}
}
if(flag==0)
{
printf("该书不存在!\n");
second();
}
}
void BookSearch()//查找图书信息
{
int i,flag;
char bookname[20];
FILE *fp;
if((fp=fopen("books_list.txt","rb"))==NULL)
{
printf("\n不能打开该文件");
return;
}
else
{
printf(" *********************\n");
printf(" * 图 书 信 息 查 询 *\n");
printf(" *********************\n");
printf("\n请输入书名:\n");
scanf("%s",bookname);
while(!feof(fp))
{
for(i=0;strlen(Book[0].name)!=0;i++)
fread(&Book[0],sizeof(struct BookList),1,fp);
fclose(fp);
for(i=0;i<1000;i++);
{
if(strlen(Book[i].name)==0) break;
else
if(strcmp(bookname,Book[i].name)==0)
{
printf("\n\n已查到该书,其资料如下:");
printf("\n书名:%s",Book[i].name);
printf("\n分类号:%d",Book[i].sort);
printf("\n主编:%s",Book[i].editor);
printf("\n出版社:%s",Book[i].publisher);
printf("\n主题词:%s",Book[i].theme);
printf("\n版次:%d",Book[i].edition);
printf("\n出版日期:%s",Book[i].publish);
printf("\nISBN:%s",Book[i].ISBN);
printf("\n定价:%f",Book[i].price);
printf("\n借阅人用户名:%s",Book[i].borrowname);
printf("\n预约人用户名:%s",Book[i].ordername);
printf("\n该书现在状况:%s",Book[i].okay);
printf("\n这本书的标记:0已借出,1可借出可预约,2已预约:%d",Book[i].yes);
flag=1;
break;
}
}
}
}
if(flag==0)
printf("\n\n查无此书。");
fclose(fp);
second();
}
void BookReturn()//归还图书
{
}
void Bookleft()//遗损处理
{
}
void AddBooks()//新书入库
{
FILE *fp;
if((fp=fopen("books_list.txt","r"))==NULL)
{
printf("file not exit");
if((fp=fopen("books_list.txt","w"))==NULL)
{
printf("new file fail!!");
exit(0);
}
}
else
{
if((fp=fopen("books_list.txt","a"))==NULL)
{printf("file add fail!\n");
exit(0);}
}
printf(" !!!!!!!!!!!!!!!!!!!\n");
printf(" !! 新 书 入 库 !!\n");
printf(" !!!!!!!!!!!!!!!!!!!\n");
printf("\n请输入新书的名字: ");
scanf("%s",&Book[0].name);
printf("\n请输入新书的分类号:");
scanf("%d",&Book[0].sort);
printf("\n请输入新书的主编:");
scanf("%s",&Book[0].editor);
printf("\n请输入新书的出版社:");
scanf("%s",&Book[0].publisher);
printf("\n请输入新书的主题词:");
scanf("%s",&Book[0].theme);
printf("\n请输入新书的版次:");
scanf("%d",&Book[0].edition);
printf("\n请输入新书的出版日期:格式为(2006 12 31):");
scanf("%s%s%s",&Book[0].publish.year,&Book[0].publish.month,&Book[0].publish.day);
printf("\n请输入新书的ISBN:");
scanf("%d",&Book[0].ISBN);
printf("\n请输入新书的定价:");
scanf("%f",&Book[0].price);
Book[0].okay=1;
Book[0].yes=1;
fwrite(&Book[0],sizeof(struct BookList),1,fp);
fclose(fp);
printf("\n您已成功向图书馆添加图书《%s》\n",Book[0].name);
second();
}
void Booking()//预约图书
{
FILE *fp;
char bookname[40];
int i,j,w,flag=0;
printf(" 预约图书\n");
printf("\n请输入图书名:");
scanf("%s",bookname);
fp=fopen("books_list.txt","rb");
if(fp==NULL)
{
printf("\n无法打开该文件! ");
return;
}
else
for(w=0;w<1000;w++)
{fread(&Book[w],sizeof(struct BookList),1,fp);
}
fclose(fp);
for(i=0;i<1000;i++)
{
if(strcmp(Book[i].name,bookname)==0)
{
flag=1;
if(Book[i].okay==1)
{
if(Book[i].yes==1)//0,已被预约;1,可借出或预约;2,已被预约
{
//getch();
printf("\n");
strcpy(Book[i].ordername,Student->name);
Book[i].yes=2;
fp=fopen("books_list.txt","wb");
for(j=0;j<1000;j++)
fwrite(&Book[j],sizeof(struct BookList),1,fp);
fclose(fp);
printf("\n预约图书成功!\n*预约期限为一个月!\n*");
second();
}
else
{
printf("\n该书已被借出或已被预约\n");
second();
}
}
else
{
printf("该书已遗损!");
second();
}
}
}
if(!flag)
{
printf("该书不存在!\n");
second();
}
}
----------------解决方案--------------------------------------------------------
就是连接的时候有两个错误,6.obj : error LNK2001: unresolved external symbol _AllBooks
6.obj : error LNK2001: unresolved external symbol _MemberBook
高手们,,帮下忙啊,,小弟急用!
----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽