Hot answers tagged

1

I would recommend forgoing all the overhead of allocating new memory on every call to hash(). Instead, consider just looping through word and replacing c with tolower(word[i]) in your hash calculation. Edit: as mentioned in another comment, the reason your free() fails is because you use the ++ increment operator to step through lowercaseword. While pointer ...


1

Interesting... 1 block, 552 bytes related to an fopen statement in load. What's the size of a file pointer? Did you remember to close the dictionary file before ending the load function? ;-) BTW, why does load return false when it completes successfully? Hint: valgrind might give you some clues about memory leaks in a program, but you should be focused ...


1

The random values you see in word is the result of previous iterations of the loop assigning longer words than the current one. It's not an issue per se since the functions handling it (such as strlen or strcpy) will just read to the first null terminator anyway. The problem lies in the hash function, and actually took me a little while to figure out. It's ...


1

Does your hash function return the same bucket for the words "apple" and "Apple"? If not, then your issue isn't strcasecmp, but the fact that you aren't looking in the right linked list.


1

Perhaps its because table[] is being reinitialized with every word processed in the while loop? This will result in only the last word's index pointer being left in the array. The table[] array needs to be initialized once. It should be done before the while loop starts, not inside the while loop. As for the seg fault, well, that may be related to something ...


Only top voted, non community-wiki answers of a minimum length are eligible