I've defined the struct as following:

    // Node struct
    typedef struct node
      // Node value
      char word[LENGTH + 1];
      // Node Pointer to next value/node
      struct node* next;

    // Hash table of node pointers
    node* hashtable[LENGTH];  

This issue is when i'm using

while(fscanf(file, "%s\n", word)!= EOF)

in my load function I get the error "use of undeclared identifier 'word'; did you mean 'load'?"

Does this mean I have to initialise an array before I declare the fscaf function such as

char word[LENGTH + 1];

I just thought this would result in creating a totally different array not related to the original struct.

Have a bit of trouble understanding calling word in this situation

I thought I could just add something such as node.word in the fscanf function instead.

while(fscanf(file, "%s\n", node.word)!= EOF)

Not sure what the pros and cons of each would as i'm assuming later on if I wanted to use the word function i.d have to declare it via "node.word"

1 Answer 1


fscanf needs some memory to write to, so char word[LENGTH + 1]; is probably the way to go. You might want to strcpy the result to a new node's word property in case of success.

Please note that the length of the hashtable can and should be chosen independently of the maximum word length. The hashtable size would be relevant for determining the index to use (like computed_hash % HASHTABLE_LENGTH).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .