Hot answers tagged

1

The seg fault lies here: char *term = NULL; while(fscanf(f, "%s", term) != EOF) { fscanf(f, "%s", term); node *nd = malloc(sizeof(node)); if (nd != NULL) { strcpy(nd->word, term); Note first that the pointer term is set to NULL. That means that no memory is allocated to that ...


1

For starters, the program doesn't actually compile without error. It's probably compiling in your environment with a warning about an unused parameter in the call to load(). In most people's environment, that would produce a warning about the unused parameter of dictionary in the signature which would be treated as an error. The root cause of that is this ...


1

The first big problems I see are in check(). Look at this line: while(cursor->next != NULL) This is going to result in every other node being skipped, among other anomalies. It should be checking cursor, not cursor->next. I'll let you figure out why. Next, there's the two free(cursor) statements in the check function. Even though you created a ...


1

It looks like most, if not all of the issues arise from one problem. In the load function, near the bottom, I found this: free(newnode); What happens when you free the node that you just created??? Doesn't it destroy the node that was just created at that address??? Copying the address to another location doesn't copy the node. So, if you have a dozen ...


1

It looks like an intermittent problem that's going to rear it's ugly head depending on what's in memory and what was in memory before. Since your whole code wasn't posted, I looked fairly closely at the load function. This jumps out at me: for (int i = 0; word[i]; i++) { w->word[i] = word[i]; } It looks like the code is trying to ...


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