I'm working on CS59 Week 5's "Speller" assignment. Currently, I'm trying to write the unload function with a test dictionary file on my desktop. But for some reason, line 91 (while(!feof(dictionary))) is returning an error:
"request for member '_flag' in something not a structure or a union"
I'm working from a new computer. My previous computer did not return this error. Can someone please explain what's going on here and how I can fix it? Thanks in advance.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
unsigned int HASH_MAX = 50;
unsigned int LENGTH = 20;
unsigned int hash (const char *word);
bool load(char *dictionary);
bool check (char *word);
bool unload (void);
void print (void);
typedef struct _node
{
    char *word[20];
    struct _node *next;
} node;
node *HASH_TABLE[50];
int main(int argc, char *argv[])
{
    FILE *dictionary = fopen("C:/Users/aaron/Desktop/Dictionary.txt", "r");
    if(!dictionary)
    {
        printf("FILE NOT FOUND\n");
        return 1;
    }
    if (load(dictionary))
    {
        // print "LIST (number): {(name, address), ...}\n
        print();
    }
    int lois = hash("Lois");
    printf("\n%s\n", HASH_TABLE[lois]->word);
    if (check("StEwIe"))
    {
        printf("STEWIE found\n");
    }
    else if (!check("StEwIe"))
    {
        printf("STEWIE not found\n");
    }
    if (check("Tron"))
    {
            printf("TRON found\n");
    }
    else if (!check("Tron"))
    {
            printf("TRON not found\n");
    }
    if (unload())
    {
        print();
    }
}
unsigned int hash(const char *word) // hash code function (FIND A BETTER ALGORITHM)
{
    char word_conv[LENGTH + 1]; // store converted word for uniform key
    unsigned int code = 0; // hash code
    for (int i = 0; i < strlen(word); i++) // set all letters in the word to lower case
    {
        word_conv[i] = tolower(word[i]);
    }
    for (int j = 0; j < strlen(word_conv); j++) // for all letters in converted word, add ascii value to code and multiply by 3
    {
        code += word_conv[j];
        code *= 3;
    }
    code = code % HASH_MAX; // set code to remainder of current code divided by maximum hash table size
    return code;
}
bool load (char *dictionary)
{
    char word[LENGTH+1];
    while(!feof(dictionary))
    {
        fscanf(dictionary, "%s", word);
        node *new_n = malloc(sizeof(node));
        strcpy(new_n->word, word);
        new_n->next = NULL;
        unsigned int code = hash(word);
        if (HASH_TABLE[code] == NULL)
        {
            HASH_TABLE[code] = new_n;
        }
        else if (HASH_TABLE[code] != NULL)
        {
            node *trav = HASH_TABLE[code];
            while (trav->next != NULL)
            {
                trav = trav->next;
            }
            if (trav->next == NULL)
            {
                trav->next = new_n;
            }
        }
    }
    return true;
}
bool check (char *word)
{
    unsigned int code = hash(word);
    node *check = malloc(sizeof(node));
    check = HASH_TABLE[code];
    while (check != NULL)
    {
        if (strcasecmp(check->word, word) == 0)
            return true;
    }
    if (check == NULL)
        return false;
}
bool unload (void)
{
    for (int i = 0; i < HASH_MAX; i++)
    {
        while (strcmp(HASH_TABLE[i]->word, "FREE" != 0)
        {
            node *curr = HASH_TABLE[i];
            node *prev = NULL;
            while (curr != NULL)
            {
                prev = curr;
                curr = curr->next;
            }
            strcpy(prev->word, "FREE");
        }
    }
    return true; // freed successfully
}
void print (void)
{
    for (int i = 0; i < HASH_MAX; i++)
    {
        node *check = HASH_TABLE[i];
        printf("LIST %02d: {", i);
        while (check != NULL)
        {
            printf("%s, ", check->word);
            check = check->next;
        }
        printf("}\n");
    }
}
