New answers tagged

0

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 ...


0

In the load() function, when you're opening the file, I don't think it's valid syntax to write FILE * dictfile = open... You should write either FILE* dictfile or FILE *dictfile. Also in the load() function, when you're creating a node, you've written node*n= ... which should be invalid syntax. Write either node* n or node *n. I think you could have found ...


0

Regarding the check50 error messages, the problem is likely that your hash function is cash sensitive (in other words, "the" returns a different hash than "The"). Remember that the speller code will call your check function with the word exactly as it appears in the text.


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.


0

The issue lies here: for (int i = 0; n = strlen(word); i < n; i++) There are actually two problems here, the undeclared var and the structure of the for statement. Both can be fixed with one change. The problem is the first semicolon. It should be a comma. When declaring multiple vars of the same type, whether in a for statement or as a separate line of ...


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 ...


0

I see a few problems in the code that are causing problems. First, table[] is not initialized. That means that all the pointers in the array contain garbage data instead of NULL when the program starts. Second, there's this: while (fscanf(file, "%s", word) != EOF) { fscanf(file, "%s", word); This is executing two sequential reads. ...


1

You should ALWAYS initialize pointers. Unless you're immediately allocating memory to them and setting them to a legitimate address, you should initialize them by setting them to NULL. Note that if the pointer or array is created as a global, it can't be assigned any value when declared. The assignment must be done inside main or inside a function. In ...


Top 50 recent answers are included