显示操作成功
但文件数据还在,程序重新启动后,删除的链表又恢复了,怎么办?
各位帮帮我吧!
int deleteBookList(struct node* head, int IBSN)
{
struct node *p=NULL, *pre=NULL;
int status = 0;
if(head!=NULL)
{
pre=head;
p=head->next;
while(p!=NULL)
{
if(p->book.IBSN==IBSN)
{
pre->next = p->next;
free(p);
status = 1;
break;
}
pre = p;
p = p->next;
}
}
return status;
}
void deleteBook(struct node *head)
{
printf("请输入要删除的图书编号:");
char a[1024];
int IBSN=0;
if (fgets(a, 1024, stdin)!= NULL &&
sscanf(a, "%d", &IBSN)!=EOF)
{
if (deleteBookList(head, IBSN))
{
printf("该编号%d对应的图书信息删除成功!\n", IBSN);
}else
{
printf("该编号对应的图书信息不存在!\n");
}
}
else
{
printf("输入有误,请重新输入!\n");
}
}