My load function sometimes overlooks certain words in the dictionary. For example it jumps over the word "nodes" instead of loading it into the hash table.
bool load(const char *dictionary) { // Open and check if NULL FILE *dictionaries = fopen(dictionary, "r");
if (dictionaries == NULL)
{
return false;
}
//read strings until EOF
int x = 0;
char words[LENGTH + 1];
node *current;
while (x == 0)
{
fscanf(dictionaries, "%s", words);
word_count++;
//create new node
current = malloc(sizeof(node));
if (current == NULL)
{
return false;
}
strcpy(current->word, words);
current->next = NULL;
//hash word
h = hash(current->word);
//insert node into hash table
if (table[h] == NULL)
{
table[h] = current;
}
else
{
current->next = table[h];
table[h] = current;
}
if (fscanf(dictionaries, "%s", words) == EOF)
{
x = 1;
}
}
return true;
return false;
}