New answers tagged

1

There are several problems in the code. Most are the same issue - a lack of understanding of what free() does. Let's say that some code allocates memory to a pointer, and that memory is 'shared' like this: node *mynode = malloc(sizeof(node)); node *yournode = mynode; Both pointers will contain the same address, pointing at the same memory. Change the ...


1

Look very carefully at all of the areas on the right side of the screen. Did you notice that the area that shows the vars and their content is called local variables? It isn't that the vars you mentioned don't exist, they're just not displayed. They are all global vars, not local. If you want to see them, you can type in their names in the area titled "...


1

There are a number of problems in this code. For starters, it's generating a seg fault in freelist. Fixing that leads to an infinite loop, indicating issues elsewhere. Additionally, it seems to be finding that every word is misspelled. All of these issues are likely intertwined. This will be an excellent learning experience in debugging! My suggestion at ...


1

This is a great lesson that a problem in one place is caused by a bug somewhere else. While the code in unload is mostly correct (there is a small flaw), the data that it's processing is flawed. If you run the program under debug50, you would see that as unload runs, both cursor and cursor->next contain the same address. In fact, if you search through ...


0

I think I found the reason the program is unable to load. This line: FILE *file = fopen("dictionary", "r"); Should be: FILE *file = fopen(dictionary, "r");


1

Ahh, the thing that makes a string a string! lword in check is not technically a string as it is not properly terminated, so the result of strcasecmp is "unreliable". You could create a text file to match the check50 test and run it with the small dictionary. But be warned, the results may be different than check50, it may even give the correct ...


Top 50 recent answers are included