拜托各位告诉小弟我哪错了,求
拜托各位告诉我哪错了,急求
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct bk {
char book_num[10];
char book_name[10];
int book_kc;
int book_xc;
struct bk * next;
}book;
struct bk *l;
void save();
void menu();
void putin();
void search() ;
void lend();
void reback();
void save(char book_num[],char book_name[],int number)
{ FILE *book_fp;
struct bk *q ,*t;
q=l;
if((book_fp=fopen("book.txt","w"))==NULL)
{ printf("不能建立图书文件!\n"); return; }
t=(struct bk *)malloc(sizeof(struct bk));
strcpy(t->book_num,book_num);
strcpy(t->book_name,book_name);
t->book_kc=t->book_xc=number;
q->next=t;t->next=NULL;
fwrite(t,sizeof(struct bk),1,book_fp);
}
void putin()
{ struct bk *q;
int number;
int y=1;
system("cls");
while(y)
{
printf("请输入您的书的编号:");
scanf("%s",q->book_num);
printf("请输入书名:");
scanf("%s",q->book_name);
printf("请输入您要存的数量:");
scanf("%d",number);
printf("\n是否继续录入(1.继续;0,退出录入):");
fflush(stdin);
scanf("%d",&y);
switch(y)
{
case 1:putin();
break;
case 0:system("cls");menu();
break;
}
}
save(q->book_num,q->book_name,number);
}
void search()
{ struct bk *p;
p=l;
printf("请输入您的书的编号:");
scanf("%s",p->book_num);
while(p!=NULL&&strcmp(p->book_num,l->book_num)!=0)
p=p->next;
if(p==NULL) printf("\n\t此编号对应的图书不存在!\n");
else { printf("\n\t图书编号\t图书名\t库存量\t现存量 \n");
printf(" %10s\t %10s\t %d\t %d\t\n",p->book_num,p->book_name,p->book_kc,p->book_xc);
}
system("cls");
menu();
}
void lend()
{ struct bk *q;
q=l;
printf("请输入您的书的编号:");
fflush(stdin);
scanf("%s",q->book_num);
while(q!=NULL&&strcmp(q->book_num,l->book_num)!=0)
q=q->next;
if(q==NULL)
printf("\n\t此编号对应的图书不存在!\n");
else { printf("\n\t图书编号\t图书名\t库存量\t现存量 \n");
printf(" %10s\t %10s\t %d\t %d\t\n",q->book_num,q->book_name,q->book_kc,q->book_xc);
q->book_xc=q->book_xc-1;
save(q->book_num,q->book_name,q->book_xc);
}
}
void reback(){
struct bk *b;
b=l;
printf("请输入您的书的编号:");
scanf("%s",b->book_num);
while(b!=NULL&&strcmp(b->book_num,l->book_num)!=0)
b=b->next;
if(b==NULL)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct bk {
char book_num[10];
char book_name[10];
int book_kc;
int book_xc;
struct bk * next;
}book;
struct bk *l;
void save();
void menu();
void putin();
void search() ;
void lend();
void reback();
void save(char book_num[],char book_name[],int number)
{ FILE *book_fp;
struct bk *q ,*t;
q=l;
if((book_fp=fopen("book.txt","w"))==NULL)
{ printf("不能建立图书文件!\n"); return; }
t=(struct bk *)malloc(sizeof(struct bk));
strcpy(t->book_num,book_num);
strcpy(t->book_name,book_name);
t->book_kc=t->book_xc=number;
q->next=t;t->next=NULL;
fwrite(t,sizeof(struct bk),1,book_fp);
}
void putin()
{ struct bk *q;
int number;
int y=1;
system("cls");
while(y)
{
printf("请输入您的书的编号:");
scanf("%s",q->book_num);
printf("请输入书名:");
scanf("%s",q->book_name);
printf("请输入您要存的数量:");
scanf("%d",number);
printf("\n是否继续录入(1.继续;0,退出录入):");
fflush(stdin);
scanf("%d",&y);
switch(y)
{
case 1:putin();
break;
case 0:system("cls");menu();
break;
}
}
save(q->book_num,q->book_name,number);
}
void search()
{ struct bk *p;
p=l;
printf("请输入您的书的编号:");
scanf("%s",p->book_num);
while(p!=NULL&&strcmp(p->book_num,l->book_num)!=0)
p=p->next;
if(p==NULL) printf("\n\t此编号对应的图书不存在!\n");
else { printf("\n\t图书编号\t图书名\t库存量\t现存量 \n");
printf(" %10s\t %10s\t %d\t %d\t\n",p->book_num,p->book_name,p->book_kc,p->book_xc);
}
system("cls");
menu();
}
void lend()
{ struct bk *q;
q=l;
printf("请输入您的书的编号:");
fflush(stdin);
scanf("%s",q->book_num);
while(q!=NULL&&strcmp(q->book_num,l->book_num)!=0)
q=q->next;
if(q==NULL)
printf("\n\t此编号对应的图书不存在!\n");
else { printf("\n\t图书编号\t图书名\t库存量\t现存量 \n");
printf(" %10s\t %10s\t %d\t %d\t\n",q->book_num,q->book_name,q->book_kc,q->book_xc);
q->book_xc=q->book_xc-1;
save(q->book_num,q->book_name,q->book_xc);
}
}
void reback(){
struct bk *b;
b=l;
printf("请输入您的书的编号:");
scanf("%s",b->book_num);
while(b!=NULL&&strcmp(b->book_num,l->book_num)!=0)
b=b->next;
if(b==NULL)