From c5f9fbf490f3bf2f64ba91989739d79d978f7ef0 Mon Sep 17 00:00:00 2001 From: fei liang rong <1057432755@qq.com> Date: Sun, 21 May 2023 10:42:47 +0800 Subject: [PATCH] query_data --- query_data.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 query_data.c diff --git a/query_data.c b/query_data.c new file mode 100644 index 0000000..1aa8a32 --- /dev/null +++ b/query_data.c @@ -0,0 +1,23 @@ +// 查询图书信息 +void query_data() +{ + int id; + struct book *p; + + printf("请输入要查询的图书编号:"); + scanf("%d", &id); + + p = find(id); // 查找编号为id的图书 + if(p != NULL) + { + printf("图书信息如下:\n"); + printf("图书编号:%d\n", p->id); + printf("图书名称:%s\n", p->name); + printf("图书作者:%s\n", p->author); + printf("图书价格:%.2f\n", p->price); + } + else + { + printf("没有找到编号为%d的图书!\n", id); + } +}