Mega Code Archive

 
Categories / C++ / File
 

Ignore( ) reads and discards characters from the input stream

// ignore has this prototype: istream &ignore(streamsize num=1, int_type delim=EOF); #include <iostream> #include <fstream> using namespace std;     int main() {   ifstream in("test");       if(!in) {     cout << "Cannot open file.\n";     return 1;   }       /* Ignore up to 10 characters or until first      space is found. */   in.ignore(10, ' ');   char c;   while(in) {     in.get(c);     if(in) cout << c;   }       in.close();   return 0; }