std::basic_istream::getline

From Cppreference

Jump to: navigation, search
basic_istream& getline( char_type* s, pos_type count );
(1)
basic_istream& getline( char_type* s, pos_type count, char_type delim );
(2)

Extracts characters from stream. For both versions if good() != true, setstate(failbit) is called and the function returns. If end-of-file occurs, setstate(eofbit) is called and the function returns.

1) reads at most count-1 characters and stores them into character string pointed to by s. The function stops if \n delimiting character is found, in which case it is extracted but not stored. The resulting string is always null-terminated.

2) reads at most count-1 characters and stores them into character string pointed to by s. The function stops if delim delimiting character is found, in which case it is neither extracted nor stored. The resulting string is always null-terminated.

Contents

[edit] Parameters

s - pointer to the character string to store the characters to
count - size of character string pointed to by s
delim - delimiting character to stop the extraction at. It is extracted but not stored.

[edit] Return value

*this

[edit] Example

[edit] See also

operator>>
extracts formatted data
(public member function)
get
extracts characters
(public member function)
read
extracts blocks of characters
(public member function)