The relevant snippet of my load function:
FILE* dict = fopen(dictionary, "r");
bool complete = true;
for (int c = fgetc(dict); c != EOF; c = fgetc(dict))
{
node* head = malloc(sizeof(node));
if (isalpha(c) && complete)
{
c = toupper(c);
head = root[c - 65];
complete = false;
}
else if (isalpha(c) || c == '\'')
{
if (c == '\'')
{
head = head->children[26];
}
else
{
c = toupper(c);
head = head->children[c - 65];
}
if (head->is_word != true)
{
head->is_word = false;
}
}
When I run speller through valgrind and gdb, speller segfaults on the line
if (head->is_word != true)
After playing around with my code I can definitely confirm that accessing the variable is_word in my node pointer causes a segfault regardless of the particular node pointer. That doesn't make any sense to me because (any node pointer x)->is_word seems like a routine operation.
E: struct node and node* head are defined globally.