Reading Lines of Text into char Built-In Arrays with cin.getline
In some cases, it’s desirable to input an entire line of text into a built-in array of
chars. For this purpose, the
cin object provides the member function getline, which takes three arguments—a built-in array of chars in which the line of text will be stored, a length and a delimiter character. For example, the statements
char sentence[ 80 ];cin.getline( sentence, 80, '\n' );
sentence as a built-in array of 80 characters and read a line of text from the keyboard into the built-in array. The function stops reading characters when the delimiter character
'\n' is encountered, when the end-of-file indicator is entered or when the number of characters read so far is one less ...