I am testing my load() with ./speller texts/austinpowers.txt and comparing the result with stuff version with stuff version ~cs50/pset5/speller texts/austinpowers.txt
I have been stuck here for a while.. Any help will be appreciated!!!
my result
stuff version
my load()
bool load(const char* dictionary)
{
root = calloc(1, sizeof(NODE));
NODE* ptr = root;
FILE* dict = fopen(dictionary, "r");
if (dict == NULL)
return false;
for (int c = fgetc(dict); c != EOF; c = fgetc(dict))
{
if(c != '\n' && c != '\'')
c = c - (int)'a';
else if (c == '\'')
c = 26;
if(c != '\n')
{
if(ptr->children[c] == NULL)
{
NODE* new_node = calloc(1, sizeof(NODE));
ptr->children[c] = new_node;
ptr = new_node;
}
else
{
ptr = ptr->children[c];
}
}
else
{
ptr->is_word = true;
ptr = root;
count++;
}
}
fclose(dict);
return true;
}