I am currently trying to solve pset5, speller. I managed to write every funtion correctly except of the check() function. This is the check() function I wrote so far:
// Returns true if word is in dictionary else false
bool check(const char *word)
{
unsigned int bucket = hash(word);
for (node *temp = table[bucket]; temp != NULL; temp = temp->next)
{
if (strcasecmp(temp->word, word) == 0)
{
return true;
}
}
return false;
}
Somehow, only strings that are either completely lowercase or completely uppercase are seen as equal to the words in the dictionary by strcsecmp. When only the first letter or any other letter or combination of letter of one string is uppercase and the rest lowercase, the function does not return 0.
I tried to solve it by using tolower() and then compare the strings but then I get an error saying something about datatypes that the strcmp() cannot be fed with.
Did I understand the strcasecmp() function wrongly? Or did I make any other mistake? I really appreciate your help!