C语言数据结构,想要进行查找元素的操作。
56行是while语句那一行,报错“wrong type argument to unary exclaimation mark”
感谢各位!
int LocateElem(List *L,struct STU e3,struct STU (*compare)(struct STU,struct STU))
{
struct STU *p;
int i=1;
p=&(L->elem);
while(i<=L->length&&!(*compare)(*p++,e3)) ++i;
if(i<=L->length) return i;
else return 0;
}
while(i<=L->length&&!compare(*p++,e3)) ++i; 就行了。