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


so code saying list , size not structure?

typedef struct hashtable{     int size;     listref **list;  } hash;  typedef struct hash *hash_ref;  hash_ref *newhash(int size){     hash_ref *hashed= null;     if(size<1){         return null;     }     if( (hashed=malloc(sizeof(hash))) ==null){         return null;     }     if( (hashed->list=malloc(sizeof(listref*)*size)) ==null){         return null;     }     for(int i=0; i<size; i++){         hashed->list[i]=null;     }     hashed->size=size;      return hashed; } 

here list function

typedef struct node{     long key;/*book id*/     listref data;     struct node* next;     struct node* prev; }nodetype;  typedef nodetype* noderef;  typedef struct listhdr{     noderef first;     noderef last;     noderef current;     long length; }listhdr; 

i wondering whats error? forgot add listhdr changed listref in list header file.. included in hashtable module.

i'm trying create 2 hash tables. 1 has table stores 2 long integers. other hashtable takes 1 long integer , linked list(which has 2 long integers).

hash_ref typedefed pointer hash, must declare hashed hash_ref hashed, not hash_ref *hashed. (the latter create pointer pointer hash.)

in addition this, should omit struct typedef declares hash_ref. hash_ref isn't declared point hash, as-yet-undeclared struct hash. compiles because compiler interprets forward declaration of struct hash. interpretation cause code tries dereference hash_ref fail errors such "storage size of struct hash unknown".


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -