getline
getline
template<class E, class T, class A>
basic_istream<E, T>& getline(
basic_istream <E, T>& is,
basic_string<E, T, A>& str);
template<class E, class T, class A>
basic_istream<E, T>& getline(
basic_istream <E, T>& is,
basic_string<E, T, A>& str,
E delim);
The first template function returns getline(is, str, is.widen('\n'))
.
The second template function replaces the sequence controlled by str
with a sequence of elements extracted from the stream is
. 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
is.
max_size
()
elements, in which case the function callssetstate
(ios_base::failbit)
.
If the function extracts no elements, it calls setstate(failbit)
. In any case, it returns *this
.
See the related sample program.