I want the user to be able to put data in to my vector by using this while-loop, and when the user enters 'end' the loop breaks.
1 2 3 4 5 6 7 8 9 10 11 12
while ( getline(Value) )
{
// are we done?
if ( Value == "end" )
{
// Yes
break;
}
// add to vector
Data.push_back ( Value );
}
I did use while ( cin >> Value ) and it did work, but when the user hits space, the next word is put on an other place in my vector. I want to be able to put in for example: "James Bond", and still on the same line.
Why does not while ( getline(Value) ) do this?
I get error mesage:
error: no matching function for call to 'getline(std::string&)'