0

I'm pretty sure my load function is working correctly, but if the dictionary does not terminate with a \n, the last word doesn't get loaded.

I know both the large and small dictionaries do indeed have a \n after the last word, so it'll load everything, but I personally want to see what the method is for loading the last word even if there is no \n after it.

I'm currently using:

while((c =fgetc(dict)) != EOF){
//My code here
if(){//Code here}
else if (c == '\n'|| c == EOF){//Bulk of my code here}
}

I think it has to do with EOF terminating early.

Thoughts and comments appreciated.

1

Are you sure that you've assessed the problem correctly? Since you're doing a trie, and without seeing your code, I'm guessing that the word is getting loaded into the trie, but you're just not closing out the process - setting is_word and incrementing the word counter.

You need to figure out a way to make sure that happens when the EOF is detected.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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