The member function istream& istream::getline(char* s, streamsize n, char delim);
enables you to extract characters from the stream until one of 3 things happens:
n - 1
characters are read from the stream, orObviously, condition 3 (an error occurs) is easy to detect. But how can the caller distinguish between conditions (1) and (2)? How can you tell if a delimiting character was, or not? It's possible that n - 1
characters were read, but a delimiting character wasn't found.
According to http://en.cppreference.com/w/cpp/io/basic_istream/getline
In situation 3, setstate(eofbit)
will be executed.
In situation 2, setstate(failbit)
will be executed.