我目前正在嘗試創建一個字符串哈希表。然而,在我的搜索功能,我已經運行到了一個錯誤:爲會員要求_的東西不是一個結構或聯合..再次C編譯錯誤:請求成員___的東西不是結構或工會
/*search hash table*/
ListC search(hash_ref h, char* key){
ListC* tempList;
int hashvalue= hashing(h, key);
46 for(tempList= h->List[hashvalue]; tempList!=NULL; tempList=tempList->next){
47 if(strcmp(tempList->key,key)==0){
return tempList;
}
}
return NULL;
}
/*hash function*/
int hashing(hash_ref h, char* key){
int hashvalue=0;
for(hashvalue=0;key!='\0';key++){
hashvalue= *key + (hashvalue*5) - hashvalue;
}
return hashvalue%h->size;
}
/*HashTable struct*/
typedef struct HashTable{
int size;
ListC **List;
}hash;
typedef struct Node{
long key;/*book id*/
long count;
struct Node* next;
struct Node* prev;
}NodeType;
typedef NodeType* NodeRef;
typedef struct ListCount{
NodeRef first;
NodeRef last;
NodeRef current;
long length;
}ListCount;
ListC在我的頭文件中定義爲
typedef struct ListCount* ListC;
在第46行和第47行,我得到一個錯誤,說明關鍵字和下一個是不是結構的成員。我不知道這裏有什麼問題
「listC」的定義是什麼? –
你如何定義struct ListC? – Amadeus
你'tempList'的類型是'指向ListC'的指針,但是你沒有展示'ListC'是如何定義的。現在,你的'Node'類型是唯一一個似乎定義了'next'字段的類型。 –