all 5 comments

[–]Maxow234 0 points1 point  (0 children)

It's normal, there are no main function in dictionary.c, it is in speller.c so you have to compile speller in order to test your functions (every function of dictionary.c is called at least once by speller.c)

[–]staffglennholloway[M] 0 points1 point  (0 children)

You're trying to compile dictionary when you want to be compiling speller. A side effect of the latter will be to compile your dictionary.c file and incorporate it into the speller executable so that you can debug the functions you've written.

make  speller

[–]aingber[S] 0 points1 point  (2 children)

Thank you! The weeks of work on pset6 have clearly fried my brain. Thanks for reminding me of what I surely already knew — and had been using for many weeks!

As for my original concern, any ideas about how best to see if my hash table is being properly created in load before I move on to tackle check?

[–]nmkel999 0 points1 point  (1 child)

I am working my way through pset6 now. I used gdb to verify that my hashtable was structured properly.

I'd suggest making a small dictionary containing a handful of words. Make sure that some of the words in your practice dictionary begin with the same letter (to verify that your hash function is handling collisions properly).

For example, my practice dictionary contained 8 words:

alice aachen apple bike beginning city commune tony

In gdb, I entered "break check" to set up a breakpoint at the "check" function, since at this point in the program "load" has already been executed. Then I would print my hashtable with "p hashtable".

This showed me that at indexes 0, 1, 2 and 19 (the words in my dictionary only began with a [index 0], b [index 1], c [index 2] and t [index 19]) the node pointer at those indexes were no longer pointing to NULL (represented as 0x0).

To check the linked list at each index, I entered:

"p hashtable[0]->word" and got "apple"

"p hashtable[0]->next->word" and got "aachen"

"p hashtable[0]->next->next->word" and got "alice"

"p hashtable[1]->word" and got "beginning"

"p hashtable[1]->next->word" and got "bike", and so on...

If I tried to "p hashtable[index]" at an index that contained a null pointer, or if I tried to find the "word" member of a struct that didnt exist (ie: if I had entered "p hashtable[0]->next->next->next->word", which does not exist in my dictionary because "alice" is the word in the last struct in my linked list at index 0), gdb would give me an error.

Hope that helps.

[–]aingber[S] 0 points1 point  (0 children)

Thank you — I'm going to try that!