bool load(const char* dictionary)
{
int counter = 0;
int hash = 0;
// define node data type for linked list
typedef struct node
{
char word[LENGTH + 1];
struct node* next;
}
node;
// declare the hash table
node* hash_table[27];
// loop through each dictionary word
while (!=EOF)
{
// create new node
node* new_node = malloc(sizeof(node));
new_node -> next = NULL;
// check for NULL
if (new_node == NULL)
{
exit(1);
}
// read in dictionary word
fscanf(dictionary, "%s", new_node -> word);
//increment dictionary word count
counter++;
// hash dictionary word
int hash = toupper(new_node -> word[0]) - 'A';
// insert word into hash table
hash_table[hash] = new_node -> next;
new_node -> next = hash_table[hash] -> next;
hash_table[hash] -> next = new_node -> next;
}
return false;
}
these are my errors
dictionary.c:47:12: error: expected expression
while (!=EOF)
^
dictionary.c:63:16: error: incompatible pointer types passing 'const char *' to parameter of type 'FILE *'
(aka 'struct _IO_FILE *') [-Werror,-Wincompatible-pointer-types]
fscanf(dictionary, "%s", new_node -> word);
^~~~~~~~~~
/usr/include/stdio.h:443:50: note: passing argument to parameter '__stream' here
extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:178:46: note: expanded from macro '__REDIRECT'
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))