一个修改链表的问题
void modify(void) /*search and modify book*/{
struct book *p,*head;
char c[50];
printf("Please enter the title of the book you want to search:\n");
fflush(stdin);
scanf("%s",c);
fflush(stdin);
head=loadbook();
p=loadbook();
while (p!=NULL){
if(strcmp(p->title,c)==0)
{
printf("Book has been found.\n");
printf("Enter to continue.\n");
getch();
fflush(stdin);
break;
}
break;
p=p->bnext;
}
if (p == NULL)
{
printf("This book does not exist!\n");
printf("Enter to return.\n");
getch();
return;
}
printf("Enter the author of this book: \n");
scanf("%s", p -> author); /*read the book's author*/
fflush(stdin);
savebook(head);
printf("Print to back to menu\n");
getch();//返回
}
文件先读取链表然后搜索书名,然后更改书名,最后保存链表
loadbook是自己写的从txt读取生成链表没问题
savebook是自己写的链表保存成txt没问题
printf("Enter the author of this book: \n");
scanf("%s", p -> author); /*read the book's author*/
fflush(stdin);这是用来修改链表中某个数据的
但是最后保存的还是没修改前的...求大神告诉