The C++ string class defines the global function getline() to read strings from and I/O stream. The getline() function, which is not part of the string class, reads a line from is and stores it into s. If a character delimiter is specified, then getline() will use delimiter to decide when to stop reading data.
For example, the following code reads a line of text from STDIN and displays it to STDOUT:
string s;
getline( cin, s );
cout << "You entered " << s << endl; ----------------------------------------------------------------- cin.getline(str[i]); -----------------------------------------------------------------
The getline() function is used with input streams, and reads characters into buffer until either:
num - 1 characters have been read,
a newline is encountered,
an EOF is encountered,
or, optionally, until the character delim is read. The delim character is not put into buffer. ------------------------------------------------------------