getline
Extract strings from the input stream line-by-line.
template<class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>& _Istr,
basic_string<CharType, Traits, Allocator>& _Str
);
template<class CharType, class Traits, class Allocator>
basic_istream< CharType, Traits >& getline(
basic_istream< CharType, Traits >& _Istr,
basic_string< CharType, Traits, Allocator >& _Str,
CharType _Delim
);
template<class Allocator, class Traits, class Allocator>
basic_istream< Allocator, Traits >& getline(
basic_istream< Allocator, Traits >&& _Istr,
basic_string< Allocator, Traits, Allocator >& _Str
);
template<class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>&& _Istr,
basic_string<CharType, Traits, Allocator>& _Str,
const CharType _Delim
);
Parameters
_Istr
The input stream from which a string is to be extracted._Str
The string into which are read the characters from the input stream._Delim
The line delimiter.
Return Value
The first function returns getline( _Istr, _Str, _Istr.widen( '\n' ) ).
The second function replaces the sequence controlled by _Str with a sequence of elements extracted from the stream _Istr.
The remaining functions are analogs to earlier ones, but with Lvalues and Rvalues.
Remarks
In order of testing, extraction stops:
At end of file.
After the function extracts an element that compares equal to delim, in which case the element is neither put back nor appended to the controlled sequence.
After the function extracts str.max_size elements, in which case the function calls setstate(ios_base::failbit).
If the function extracts no elements, it calls setstate(failbit). In any case, it returns _Istr.
Example
See string::getline for an example of using getline.
Requirements
Header: <string>
Namespace: std