I'm trying to write a program that gets a sequence of words, put them into a vector and then does things with them. I've found one way that works, which is:
{
vector<string> inputs;
string Input;
cin >> Input;
while (Input != "Quit")
{
inputs.push_back(Input);
cin >> Input;
}
}
However I'm trying to use another method to do it, which is:
{
istream_iterator<string> ii(cin);
istream_iterator<string> eos;
vector<string> inputs(ii, eos);
}
But I have no idea how to make Quit
mean EOF, which would end the input stream and put the words into the vector. How do I make the string "Quit"
act as a stream terminator?