From d5185f9107c25c0aabc0532266aabc397e12cf69 Mon Sep 17 00:00:00 2001 From: yujia jin <3225852021@qq.com> Date: Sun, 21 May 2023 10:35:47 +0800 Subject: [PATCH] 1 --- app.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app.c b/app.c index a408040..23630ca 100644 --- a/app.c +++ b/app.c @@ -130,4 +130,31 @@ void add_data() books = p; // 新节点成为链表头 printf("图书信息添加成功!\n"); +} +// 更新图书信息 +void update_data() +{ + int id; + struct book *p; + + printf("请输入要修改的图书编号:"); + scanf("%d", &id); + + p = find(id); // 查找编号为id的图书 + if(p != NULL) + { + printf("请依次输入修改后的图书信息:\n"); + printf("图书名称:"); + scanf("%s", p->name); + printf("图书作者:"); + scanf("%s", p->author); + printf("图书价格:"); + scanf("%f", &p->price); + + printf("图书信息修改成功!\n"); + } + else + { + printf("没有找到编号为%d的图书!\n", id); + } } \ No newline at end of file