int status;
status=hsearch_r(wishFind,FIND,&(h->retElem),(h->htab));
print("Debug: status is %d\n",status);
结果显示状态为
-8400,但 wishFind 不在 h->htab 中。
I think status need to be 0.
it's confused me that status is -8400.
Thanks!
从手册页:
hsearch_r() 成功时返回非零值,错误时返回 0。
这意味着它允许在成功时返回任何非零值,因此您需要满足这一点:
if (status == 0) {
// failure
} else {
// success
}
如果您要查找的内容确实不在哈希表中,那么您遇到的问题与您向我们展示的代码完全不同。