I'm looking for help with my (hash) code in check to properly handle misspelled words with apostrophes and substrings:
bool check(const char *word)
{
int len = strlen(word);
char copy[len + 1];
copy[len] = '\0';
for (int i = 0; i < len; i++)
{
if (isupper(copy[i]))
{
copy[i] = tolower(word[i]);
}
else if (islower(copy[i]))
{
copy[i] = word[i];
}
else if (copy[i] == ('\'' && i > 0))
{
copy[i] = word[i];
}
}
int copyindex = hash(copy) % N;
return copyindex;
node *cursor = hashtable[copyindex];
while (cursor != NULL)
{
if (strcmp(cursor->word, copy) == 0)
{
return true;
}
cursor = cursor->next;
}
return false;
}