3.3) Reading Entire Lines Of Text
string text; cout << "Enter some text: "; getline(cin, text);
The main limitation of using >> for input is that it stops at whitespace characters. It is therefore not suitable for reading in entire lines of text, which might contain spaces. For this, the getline
function can be used, as shown above. The first argument is an istream
object and the second argument is a string
variable to hold the text.