istream::ignore
istream& ignore ( streamsize n = 1, int delim = EOF ); | stdio.h |
cplusplus.com |
Extract and discard characters.
Extracts characters from input stream and discards them.
Extraction ends when n characters have been discarded or
when delim is found, whichever comes first. In this last case
delim is also extracted.
Parameters.
Return Value.
The function returns *this
Example.
// istream ignore
#include <iostream>
using namespace std;
int main () {
char first, last;
cout << "Enter your first and last names: ";
first=cin.get();
cin.ignore(256,' ');
last=cin.get();
cout << "Your initials are " << first << last;
return 0;
}
This example shows the use of ignore to ignore input characters until a whitespace is found.
Basic template member declarations ( basic_istream<charT,traits> ):
typedef traits::int_type int_type; basic_istream& ignore (streamsize n = 1, int_type delim = traits::eof() ); |
See also.
peek,
get,
getline,
read,
readsome
istream class