Here is my dictionary loading code, however the code keeps falling and giving me a bunch of numbers and "mallocing aborted core dump" Can someone help please?Problematic_code error_valgrind


The statement for(int i=o; dictionary[i] != EOF; i++) is a nearly infinite loop. dictionary is a char array, used to hold the name of the dictionary file. It is not a pointer to a file. The filename variable is used to set a pointer to a file with fopen and to manipulate a file with the pointer. You haven't opened the dictionary file anywhere in the code that is shown, so it will never see an end of file marker ( unless maybe if all of system memory is used up.)

From what's posted, there's no way to see how you're trying to load words from the dictionary file into the memory structure.

Your best bet is to go back to the course material and review how to open files and how to copy data from the file into a buffer variable and try again.

  • Are you structuring it as a linked list of dictionary words or a trie of individual letters? And are you using fscanf or fgetc, depending on the structure, to read the words/letters? – ronga May 11 '15 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .