Regarding the check50 error messages, the problem is likely that your hash function is cash sensitive (in other words, "the" returns a different hash than "The").
Remember that the speller code will call your check function with the word exactly as it appears in the text.
The random values you see in word is the result of previous iterations of the loop assigning longer words than the current one. It's not an issue per se since the functions handling it (such as strlen or strcpy) will just read to the first null terminator anyway.
The problem lies in the hash function, and actually took me a little while to figure out. It's ...
That free statement only executes if the word is spelled wrong. If spelled correctly, the return true statement executes and the free() call is not executed.
Two possible fixes.
You could add a free statement just before the return true statement.
Or, instead of using a node pointer and allocating memory to it, just create a node variable and use it. This ...
You should put the first for loop in the load function at the start. Loops are always supposed to be inside a function, be it main or something else. therefore the particular error is generated.
Hope this helps. If this helps then please check the tickmark.
The issue lies here:
for (int i = 0; n = strlen(word); i < n; i++)
There are actually two problems here, the undeclared var and the structure of the for statement. Both can be fixed with one change.
The problem is the first semicolon. It should be a comma.
When declaring multiple vars of the same type, whether in a for statement or as a separate line of ...
Perhaps its because table is being reinitialized with every word processed in the while loop? This will result in only the last word's index pointer being left in the array.
The table array needs to be initialized once. It should be done before the while loop starts, not inside the while loop.
As for the seg fault, well, that may be related to something ...
The problems are in unload. There are two issues to deal with. I'll point you at them and let you figure out how to resolve them. ;-)
First, the while loop is based on the value in table[j]. The node pointed to by table[j] will get freed in the first pass through the loop. That leaves an invalid address in table[j]. I'm not sure why the loop is ...
I see a few problems in the code that are causing problems.
First, table is not initialized. That means that all the pointers in the array contain garbage data instead of NULL when the program starts.
Second, there's this:
while (fscanf(file, "%s", word) != EOF)
fscanf(file, "%s", word);
This is executing two sequential reads. ...
You should ALWAYS initialize pointers. Unless you're immediately allocating memory to them and setting them to a legitimate address, you should initialize them by setting them to NULL.
Note that if the pointer or array is created as a global, it can't be assigned any value when declared. The assignment must be done inside main or inside a function. In ...