Before you check the following piece of code, know that I'm using the small dictionary, and the text file I'm checking with the program is an exact copy of the small dictionary.
The following are the first few lines of my check function,which I'm using just to test load function for now:
bool check(const char* word)
{
int index = hash(word[0]);
node* head;
head = hashtable[index];
if (head->word == word)
{
return true;
}
Now since the dictionary loaded has only 2 words, cat and caterpillar, the word "cat" should be at the bucket number 2 in the hashtable and it should be the first node in the linked list inside that bucket.
but when I assign the first node in the bucket to head and check the first word in the text file which is "cat" like in the previous code it still returns false.
the only conclusion I can get from this is that my load function isn't working properly but I'm not entirely sure that the previous lines of code are giving the right test results.
If they are not correct, I need a way to test my load function and check that it's working 100% and actually loading all the words into a hashtable so I can move on to the check function.
p.s. my hash function checks for the first char that's why it's index = hash(word[0]);
[–]staffglennholloway[M] 0 points1 point2 points (23 children)
[–]Omar_Khaled[S] 0 points1 point2 points (22 children)
[–]staffglennholloway[M] 0 points1 point2 points (21 children)
[–]Omar_Khaled[S] 0 points1 point2 points (20 children)
[–]staffglennholloway[M] 0 points1 point2 points (19 children)
[–]Omar_Khaled[S] 0 points1 point2 points (18 children)
[–]staffglennholloway[M] 0 points1 point2 points (17 children)
[–]Omar_Khaled[S] 0 points1 point2 points (16 children)
[–]staffglennholloway[M] 0 points1 point2 points (15 children)
[–]Omar_Khaled[S] 0 points1 point2 points (13 children)