Hi folks.
I'm having some trouble with a program I'm working on. What it is is a chatbot based on eliza. Part of the program tokenizes what ever the user inputs. The problem I'm having is that the tokenizeing function stores the input into a vector. What I need to do is loop through the vector looking for 2 words within it, and I haven't got a clue on how to do it.
If you need any more code from the program just ask.
Any help would be much appreciated.
void tokenize(const string& str, vector<string>& tokens, const string& delimiters )
string::size_type lastPos;
string::size_type pos;
tokens.clear(); // Make sure the vector is empty to start with
// Find the first "word" (token)
lastPos = str.find_first_not_of(delimiters, 0); // Skip delimiters at beginning.
pos = str.find_first_of(delimiters, lastPos); // Find first "non-delimiter".
while ( (pos != string::npos) || (lastPos != string::npos) )
{
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Find the next word
lastPos = str.find_first_not_of(delimiters, pos); // Skip delimiters.
pos = str.find_first_of(delimiters, lastPos); // Find next "non-delimiter"
}
}