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;
\0
being present so that it knows where the string ends. Also, strcmp returns any one of 3 answers - a positive number if the second string is "greater" (lexicographically), a negative number if the first string is "greater", or 0 if they are the same. The problem in your change is that if the two strings are identical, strcmp() returns 0, which evaluates as false, introducing another error into your program. I still think the problem lies in load and not in check.\n
at the end of each word? This wouldn't show if your test text file is one word per line. Here's a test. Create a short test dictionary, then a short test file using all the same words in the dictionary, but all on one line, separated by spaces. If it fails, there's a good chance it's the\n
problem. If you can't find the problem, please edit the question and add load and any hash function, along with anything else required for load and check.