Below, I want to turn each letter in the array of word into lower case. I'm using a loop and tolower to change each letter. But I get this error when I compile:
dictionary.c:44:33: error: read-only variable is not assignable word[i] = tolower(word[i]);
Per the pset instructions, I can't change the type of word. Thoughts?
bool check(const char* word)
{
// Hash the word
int index = 0;
if(word[0] == '\'')
{
index = HASHLENGTH;
}
else
{
index = (tolower(word[0]) - 'a') % HASHLENGTH;
}
// Initialize the return value
bool result = false;
for(node* cur = HASHTABLE[index]; cur != NULL; cur = cur->next)
{
// turn to lower case
for(int i = 0; i < strlen(word); i++)
{
word[i] = tolower(word[i]);
}
if(strcmp(cur->word, word) == 0)
{
result = true;
break;
}
}
return result;
}