My speller problem compiles and, as far as I know it, I can load and unload the dictionary correctly, but I'm not getting the expected output with check. I'm pretty inexperienced with code (CS50 is my first time messing around with it) so I'm having a hard time actually finding where my problem is
Here's my code for check:
bool check(const char *word)
{
// create cursor pointer
struct node *cursor = root;
FILE *wrdCheck = fopen(word, "r");
if(wrdCheck == NULL)
{
return false;
}
while(feof(wrdCheck) == 0)
{
char t = fgetc(wrdCheck);
//checks if its alphabetical letter
if(isalpha(t))
{
t = toupper(t);
//checks if existis
if(cursor -> children[t - 'A'] == NULL)
{
cursor = root;
return false;
}
//moves cursor
else
{
cursor = cursor -> children[t - 'A'];
}
}
// checks if apostrophe character
else if(t == '\'')
{
// checks if exists
if(cursor -> children[26] == NULL)
{
cursor = root;
return false;
}
//moves cursor
else
{
cursor = cursor -> children[26];
}
}
// checks if its any other character (end of word)
else
{
if(cursor -> is_word == true)
{
cursor = root;
return true;
}
else
{
cursor = root;
return false;
}
}
}
//closes file
fclose(wrdCheck);
return false;
}