为什么这个查询功能出来不了内容啊!
void Check()
{
system("cls");
FileRead(head);
struct BOOK* q = (struct BOOK*)malloc(sizeof(struct BOOK));
q = head;
char ch[50];
gotoxy(30, 15); printf("请输入需要查询图书的编号或书名或作者:");
gotoxy(30, 17); scanf("%s", ch);
system("cls");
int t = 0;
while (q->next != NULL)
{
if (strcmp(ch, q->next->ISBN) == 0 || strcmp(ch, q->next->bookname) == 0 || strcmp(ch, q->next->writer) == 0)
{
gotoxy(5, 6); printf("------------------------------------------------------------------------------------------------------------------------------\n");
gotoxy(10, 8); printf("图书登录号 书名 作者 分类号 出版单位 出版时间 图书价格 图书数量\n");
gotoxy(5, 10); printf("------------------------------------------------------------------------------------------------------------------------------\n");
gotoxy(10, 11 + t); printf("%s", p->next->ISBN);
gotoxy(25, 11 + t); printf("%s", p->next->bookname);
gotoxy(48, 11 + t); printf("%s", p->next->writer);
gotoxy(68, 11 + t); printf("%s", p->next->ICS);
gotoxy(80, 11 + t); printf("%s", p->next->publisher);
gotoxy(97, 11 + t); printf("%s", p->next->data);
gotoxy(109, 11 + t); printf("%g", p->next->price);
gotoxy(120, 11 + t); printf("%d\n", p->next->num);
t += 2;
}
q = q->next;
}
if (t == 0)
{
system("cls");
gotoxy(30, 11); printf("这本书还没有添加入库!!!");
}
}
调试下,看看p这个链表是否有内容,并且你输入的 ch 是否匹配你的数据
不清楚FileRead如何实现,无法进一步判断
在[上一篇文章]中,我们已经关于一个简单的C++程序中函数由哪些元素构造和基本的代码风格进行了了解。容易知道,除了一些必要的预处理命令:
#include<iostream> //使用输入流和输出流的库
还需要函数头、函数体和终止命令等元素。
int main() //函数头
{
/*
函数体
*/
return 0; //终止函数的执行
}