I need to capture user input with each word stored in a separate variable. I also need to pause (like with cin) to let the user respond. I'm having trouble with getline because I can't make it pause, and cin ignores whitespace, which is my de facto delimiter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
string response;
string my_name;
vector<string> names;
cout << "Enter names";
getline(cin, response); //store the entire input sequence in one variable
istringstream instr(response);
cout << endl;
while (instr >> my_name)
{
names.push_back(my_name);
}
This compiles, but it won't wait for the user. It just plows right through. Anyone know what I should do to make the system wait for input, but still delimit with the whitespace character?
Perhaps you could benefit from checking the istream library page. There are various functions that do not ignore whitespace. That page can be found here: http://cplusplus.com/reference/iostream/istream/
Hope that library page can help :)