Standard example. I have a large text file and I wish to lex it into words. I tell the program that all words are delimited by ' ' ';' ':' and '\n'.
When I run the program it seems to be outputting the occurances of the letters and not the words. Im gobsmacked, I dont know what the hell is going on. Heres the function that lexes letters and not words. I want words dammit words!!
First youll see I define root node and point it to null; This forms the base of the BST.
Then keep munching one character at a time until EOF reached. If the character is not a delimiter, assign it to "word" string, character by character. If it is a delimiter, take the so-far-constructed "word" and chuck it in the BST, then clear the word string through .clear().
Repeat until done. But its not working.
EDIT: All the other functions in the source file are just fine, I've tested them in other apps and they are purpose built.Code:struct masternode* lexical_scanner(ifstream* inputfile) { string word; char c; struct masternode* root = NULL; while (c!=EOF){ if((c = (*inputfile).get()) != ' ' && c != ':' && c!= ';' && c!='\n') word += c; root = insert(root, word); word.clear(); } return root; }