istream& getline (char* s, streamsize n );istream& getline (char* s, streamsize n, char delim );
'\n'
) for the first form, and delim for the second: when found in the input sequence, it is extracted from the input sequence, but discarded and not written to s.(n-1)
characters have already been written to s. Note that if the character that follows those (n-1)
characters in the input sequence is precisely the delimiting character, it is also extracted and the failbit flag is not set (the extracted sequence was exactly n characters long).'\0'
) is automatically appended to the written sequence if n is greater than zero, even if an empty string is extracted.true
). Then (if good), it extracts characters from its associated stream buffer object as if calling its member functions sbumpc or sgetc, and finally destroys the sentry object before returning.*this
).flag | error |
---|---|
eofbit | The function stopped extracting characters because the input sequence has no more characters available (end-of-file reached). |
failbit | Either the delimiting character was not found or no characters were extracted at all (because the end-of-file was before the first character or because the construction of sentry failed). |
badbit | Error on stream (such as when this function catches an exception thrown by an internal operation). When set, the integrity of the stream may have been affected. |
|
|