2013-11-21 31 views
0

我已經爲插入和搜索圖書館系統的圖書創建編碼,但現在我被困在如何更新我已插入的書籍詳細信息?如何修改C++鏈接列表中的數據3

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; 
    } 
} 
+0

你至少可以增加更新函數的外觀嗎? – wimh

+0

首先,輸入條碼搜索我們要編輯的書籍,然後,我們編輯書籍的所有信息 – user2947488

回答

0

嘗試一下,如何使用鏈接列表的基本方式。

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; 
    } 
}