Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.


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

© 2015 Microsoft