}
}
return select; //返回要操作的编号
int select_menu(){ //菜单挑选函数 int sel=menu(),a=0;
switch(sel){
case 1:printf_file();system(\
case 2:add_file();system(\ case 3:delet_file();system(\ case 4:borrow();system(\ };
books *read_file(){ //文件读取函数 FILE *np;
case 5:huan();system(\ case 6:a=1;break; } return a;
books *p,*q,*head,A; head=p=NULL;
if((np=fopen(\
printf(\
fscanf(np,\
r,A.state);
if(strcmp(\
已
借
出
\
fscanf(np,\
while(!feof(np)){
p=(books*)malloc(sizeof(books));
p->id=A.id;strcpy(p->name,A.name);strcpy(p->ISBN,A.ISBN);
p->price=A.price;strcpy(p->writer,A.writer);strcpy(p->state,A.state);
if(strcmp(\
已
借
出
\
{strcpy(p->stu.name,A.stu.name);strcpy(p->stu.id,A.stu.id);strcpy(p->stu.sex,A.stu.sex);}
fscanf(np,\
if(head==NULL) head=p; else q->next=p; q=p;
r,A.state);
if(strcmp(\
已
借
出
\
fscanf(np,\
}
}
q->next=NULL;fclose(np); return head;
void write_file(Linkbook head){ //文件重新写入函数
Linkbook p=head;FILE *np;
if((np=fopen(\
printf(\
while(p!=NULL){
fprintf(np,\price,p->writer,p->state);
if(strcmp(\
已
借
出
\
fprintf(np,\ }
void printf_file(){ //信息查询函数 Linkbook p=read_file();system(\ printf_title();
}
else fprintf(np,\
p=p->next;
fclose(np);
while(p!=NULL){ printf(\
作
者
:
%s)\\tISBN:%s\\t
单
价%.2f\\t%s\\t\
if(strcmp(\
已
借
出
\
printf(\ }
void delet_file(){ //人员删除函数 int i,n=1;
Linkbook head,p=read_file(),q=p;head=p; }
else printf(\ p=p->next;
printf_file();
printf(\请输入要删除的图书编号\\n\
while(p!=NULL){ if(i==p->id)
if(n==1) {head=p->next;break;} else break;
q=p;
p=p->next; ++n;
}
相关推荐: