I've been stuck on this for hours, please help.
bool check(const char *word)
{
char check_buffer[LENGTH + 1];
for(int i = 0; i < strlen(word); i++)
{
check_buffer[i] = word[i];
}
printf("%s\n", check_buffer);
unsigned int index = hash(word);
node *cursor = table[index];
if(strcasecmp(check_buffer, cursor->word) == 0)
{
return true;
}
else
{
while(cursor != NULL)
{
printf("%s\n", cursor->word);
if(strcasecmp(check_buffer, cursor->word) == 0)
{
return true;
}
cursor = cursor->next;
}
return false;
}
}
Valgrind is reporting that my immense memory leaks are ocurring somewhere in the midst of the check function.
Besides that, whenever I run my code, many words are printed out "printf("%s\n", check_buffer)" from glitched with extra characters on the end: from aaa clinicalcg aardvark databasesg aalesund and aachen registriesg ab B7_ a Use
This looks alot like an "off-by-one" glitch, whereby those characters are garbage values.
So how do I fix this??