Export (0) Print
Expand All
4 out of 4 rated this helpful - Rate this topic


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( )



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


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;



Sample Output


Header: <istream>

Community Additions

© 2014 Microsoft. All rights reserved.