Namespaces
Variants
Views
Actions

std::getline

From cppreference.com
< cpp‎ | string‎ | basic string
Revision as of 17:58, 2 August 2011 by P12bot (Talk | contribs)

Template:cpp/string/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <string>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
template< class CharT, class Traits, class Allocator >

std::basic_istream<CharT,Traits>& getline( std::basic_istream<CharT,Traits>& input,
                                           std::basic_string<CharT,Traits,Allocator>& str

                                           CharT delim );
</td>

<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
template< class CharT, class Traits, class Allocator >

std::basic_istream<CharT,Traits>& getline( std::basic_istream<CharT,Traits>&& input,
                                           std::basic_string<CharT,Traits,Allocator>& str

                                           CharT delim );
</td>

<td > (1) </td> <td > Template:mark c++0x feature </td> </tr> <tr class="t-dcl ">

<td >
template< class CharT, class Traits, class Allocator >

std::basic_istream<CharT,Traits>& getline( std::basic_istream<CharT,Traits>& input,

                                           std::basic_string<CharT,Traits,Allocator>& str );
</td>

<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
template< class CharT, class Traits, class Allocator >

std::basic_istream<CharT,Traits>& getline( std::basic_istream<CharT,Traits>&& input,

                                           std::basic_string<CharT,Traits,Allocator>& str );
</td>

<td > (2) </td> <td > Template:mark c++0x feature </td> </tr> Template:ddcl list end

Reads in unformatted data from a stream into a string. Stops once a character equal to the delimiter is found, or the stream is exhausted. The first version uses delim as the delimiter, the second version uses Template:cpp as the delimiter. The delimiter character is discarded from the stream and not placed in the string.

Parameters

input - the stream to get data from
str - the string to put the data into
delim - the delimiter character

Return value

input

Example

Template:example cpp