在单链表里查找最喜爱的图书,有一个比较的语句,这是我图书信息的结构体
struct information {
char booknum[20];
char bookname[20];
float price = 0.0f;
};
功能函数
void favorite(Linklist &L, int *num, int *sum0) {
Linklist p, ptr = 0;
int t = 0, n = *num, sum = *sum0, i = 0, k = 0;
char string[10][60] = { 0,0 };
cout << "请输入最爱图书" << endl;
for (; sum > 0; sum--) {
cin >> string[t];
t++;
}
i = 0;
for (; *sum0 > 0; (*sum0)--) {
k = 0;
p = L->next;
while (p->data.price != 0) {
if (!strcmp(string[i],p->data.bookname)) {
cout <<" "<< p->data.booknum <<" "<< p->data.bookname <<" "<< p->data.price << endl;
p = p->next;
k++;
i++;
break;
}
p = p->next;
}
if (k == 0) {
cout << "抱歉,没有你最喜爱的图书" << endl;
i++;
}
}
}
比较语句if (!strcmp(string[i],p->data.bookname))改成if (string[i]==p->data.bookname)就一直跳过,为啥啊????