我已经为插入创建了编码,并为图书馆系统搜索书籍,但现在我被困在如何更新我插入的书籍详细信息上?
void Node::insert(char *barcode,char *title,char *author,char *quantity,char *price)
{
daftar *newnode=NULL;
newnode=new daftar(barcode,title,author,quantity,price);
if(head==NULL)
{
head=newnode;
}
else
{
newnode->setnext(head);
head=newnode;
}
}
试试类似的、使用链接列表的基本方法。
void Node::update(char *barcode,char *title,char *author,char *quantity,char *price)
{
Node* tmp = new Node();
tmp = head;
while(tmp != NULL)
{
if(strcmp(tmp->title,title) == 0)
{
tmp->barcode = barcode;
tmp->author = author;
tmp->quantity = quantity;
tmp->price = price;
return;
}
else
tmp = tmp->next;
}
}