} }
Book *Query(Book *head,char *name) { Book *p; p=head;
while(strcmp(name,p->Name)!=0&&p->next!=NULL) p=p->next;
if(strcmp(name,p->Name)==0) /*找到了,返回结点地址*/ return(p);
else /*找不到返回空指针*/ return(NULL); }
void Query_a_record(Book *head) { char name[20]; Book *p;
scanf(\ p=Query(head,name); if(p!=NULL) /*找到了*/
{ printf(\ p->Name,p->all,p->left,p->borrow); } else
printf(\找不到*/ }
Book *AddfromText(Book *head,char *filename) { FILE *fp; int n,i;
if((fp=fopen(filename,\
{printf(\打不开所指定文件*/ return(head);}
fscanf(fp,\待插入记录个数*/ for(i=0;i p=(Book *)malloc(LEN); fgetc(fp); /*读取换行符*/ fscanf(fp,\ head=Insert(head,p); /*插入结点*/ } printf(\ fclose(fp); return(head); } Book *WritetoText(Book *head,char *filename) {FILE *fp;Book *p; if(head==NULL) {printf(\ return(head);} fp=fopen(filename,\打开文件*/ p=head; while(p!=NULL) { fprintf(fp,\文件输出 */ p=p->next;} printf(\输出写到文件完毕的信息*/ fclose(fp); return(head); } void Quit(Book *head) {Book *p,*p1,*p2;FILE *fp; char filename[]=\ p2=p1=head; if(head!=NULL) {fp=fopen(filename,\打开文件*/ p=head; while(p!=NULL) { fprintf(fp,\文件输出*/ p=p->next;} printf(\输出写到文件完毕的信息*/ fclose(fp);} while(p1!=NULL) /*p1指向的结点不是空指针*/ {p2=p1->next; free(p1); /*释放存储空间*/ p1=p2; /*p1后移一个结点*/ }}