list - C Compilation error: request for member ___ in something not a structure or union -


i'm trying create hash table of strings. in search function i've been running error: request member _ in not structure or union.. again

 /*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 defined in header file

typedef struct listcount* listc; 

at lines 46 , 47 error saying key , next members not structure. i'm not sure what's problem here

typedef struct listcount* listc; 

so listc pointer type.

listc* templist; 

templist pointer pointer listcount.

... templist=templist->next ... 

templist not point structure has member named next.

i suggest illustrates why defining typedef pointer type bad idea. have keep track of levels of indirection anyway; it's typically easier if pointer types explicit.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -