how does the find STL function work with strings? The code below doesn't work correctly. The purpose is to build a list of unique words. If the word is not in the vector, then add it.
Code:void foo() { fstream stream; vector<string> theList; string oneWord; stream.open(...); // open the file for reading while( !stream.eof()) { stream >> oneWord; vector<string>::iterator pos; pos = find( theList.begin(), theList.end(), oneWord); if(pos == NULL) theList.push_back(oneWord); } }




Reply With Quote