Partager via


basic_istream::ignore

Causes a number of elements to be skipped from the current read position.

basic_istream<Elem, Tr>& ignore(
      streamsize _Count = 1,
      int_type _Delim = traits_type::eof( )
);

Parameters

  • _Count
    The number of elements to skip from the current read position.

  • _Delim
    The element that, if encountered before count, causes ignore to return and allowing all elements after _Delim to be read.

Return Value

The stream (*this).

Remarks

The unformatted input function extracts up to _Count elements and discards them. If _Count equals numeric_limits<int>::max, however, it is taken as arbitrarily large. Extraction stops early on end of file or on an element _Ch such that traits_type::to_int_type(_Ch) compares equal to _Delim (which is also extracted). The function returns *this.

Example

// basic_istream_ignore.cpp
// compile with: /EHsc
#include <iostream>
int main( ) 
{
   using namespace std;
   char chararray[10];
   cout << "Type 'abcdef': ";
   cin.ignore( 5, 'c' );
   cin >> chararray;
   cout << chararray;
}

abcdef

def

Requirements

Header: <istream>

Namespace: std

See Also

Concepts

basic_istream Class

basic_istream Members

iostream Programming

iostreams Conventions