Export (0) Print
Expand All

basic_istream::ignore 

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


basic_istream& 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.

The stream (*this).

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.

// 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;
}

Input

abcdef

Sample Output

def

Header: <istream>

Community Additions

ADD
Show:
© 2014 Microsoft