How to read a complete line from the user using cin?

The code cin >> y; only reads in one word, not the whole line. To get a line, use:

string response;
getline(cin, response);

Then response will contain the contents of the entire line.

Leave a Comment