Skip to main content
edited title
Link

pset5 Misspellings - passes check50 - doesn't work with larger text file

Source Link

pset5 Misspellings - passes check50 - doesn't work with larger text

I've been pulling my hair out over Misspellings and I've finally got it to the point where is passes check50. Though when I run the code with austinpowers.txt for example, it says I have 19188 misspelled words.

I'm pretty sure that my load function works okay, I believe the issue might be with check, sometimes the custom text files I'm testing check with will miss the last word in the file depending of the length of the file. I'm really stuck, any help would be amazing. Here is my check function:

bool check(const char* word)

char wordlower[LENGTH + 1];
int wordlength = strlen(word);    

for (int i = 0; i <= wordlength; i++)
{
    if(isalpha(word[i]))
    {
        wordlower[i] = tolower(word[i]);
    }
    else
    {
        wordlower[i] = word[i];
    }
}

node* checker = hashtable[hash(wordlower)];
    
while (checker)
{
    if(strcasecmp(checker->word, wordlower) == 0)
    {
        return true;
    }
    checker = checker->next;
}

return false;