I am currently working on a program that reads the contents from a file and then puts these contents into a trie. The contents of the file are all of words in the English Language. The problem I am having is that it appears that my code is getting stuck in my while loop, I know the words are getting inserted due to my insert function returning 1 or true. So I don't why my code is getting stuck in my while loop. Any help would be amazing.
I have already tried saying if the string words is more than the buffer than stop, I have tried using getline as my loop condition, by none of those solutions seem to work.
Below is my code:
Trie t1 = Trie();
string words;
fstream myfile;
myfile.open("wordlist.txt");
while(!myfile.eof()){
getline(myfile, words, ' ');
t1.insert(words);
}
myfile.close();