So I am trying to make a BST function that adds words from a .txt file. I want the function to add word, with the first letter as a sibling and all following letters as children. If a word has already been entered I don't want to reenter the word onto the tree, I just want to increment a variable that indicates there is more than one of these words.
So the code that I have just prints This(the first word in the .txt file) over and over again. It doesn't appear to get past 't' in this though. How would I make it go to the following letters in word?
Code:Node::AddAWord(char word[]) { cout<<word<<endl; if(letters!=*word) { if(sibling==0) { sibling=new Node(*word); sibling->AddAWord(word); } else { sibling->AddAWord(word); } } else { if(child == 0) { // cout<<word[k]<<endl; child=new Node(*word); child->AddAWord(word); } else { // cout<<word[k+1]<<endl; child->AddAWord(word); } } }



LinkBack URL
About LinkBacks


