Quote:
When you read in strings, sometimes you want to read a whole line at a time. There is a special function, getline, which can be used to read in the whole line. It will even automatically discard the newline character at the end.
To use getline, you pass in a source of input, in this case cin, the string to read into, and a character on which to terminate input. For example, the following code reads the user's first name:
getline( cin, user_first_name, '\n' );
- Alex Allain, Jumping into C++
And do you even need to put std:: in front of cin? Namespace std is being used so I'm not sure you need to. There's no std:: in front of cout in your code.