如何修改c++链表中的数据3
How To Modify Data In a c++ Linked List 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;
}
}
试试类似的、使用链接列表的基本方法。
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;
}
}
相关文章:
- 链表,反向函数,数据结构
- 为什么C中的通用链表中存储的数据已损坏
- 将从格式化文本文件读取的文本数据存储到链表
- 我对数据结构、双向链表有一些问题
- 如何在 c++ 中比较 2 个链表并将匹配的数据放入另一个链表中
- 使用带有链表的堆栈数据结构将中缀转换为后缀
- 为什么当我尝试搜索双链表中第一个数据条目之外的数据时,程序崩溃了?
- 使用链表数据结构打印多项式
- 修改链表主函数代码,用户将在其中输入节点的索引和数据以及正确的消息
- 如果我们不创建一个新节点并使用指针插入数据并建立链接(在链表中)怎么办?
- 无法在链表 C++ 中追加数据
- 如何通过其持有的数据从链表中删除某个节点?
- 基于给定字符串数据类型的链表删除节点
- 程序 使用链表插入数据时停止工作
- 尝试与 OpenMP 并行处理链表数据
- 链表数据访问
- 链表数据结构
- 链表数据结构中的C++重载运算符>>
- 如何删除双链表数据并返回它
- 链表数据编辑删除整个链表