This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/cplbexam/iostream/istream/eatwhite.cpp

31 lines
588 B
C++
Raw Permalink Normal View History

# include <iostream.h>
# include <fstream.h>
class mystream : public ifstream {
public:
mystream ( char *name ) : ifstream ( name ) {};
mystream &operator >> ( char& );
};
mystream &mystream::operator >> ( char &ch ) {
this->eatwhite();
// *((istream *)this) >> ch;
this->istream::operator >> ( ch );
return *this;
}
void main( void ) {
char ch;
mystream test ( "temp.txt" );
test.unsetf( ios::skipws );
cout << "The content of \"temp.txt\" without spaces:" << endl;
while( (test >> ch).good() ) {
cout << ch;
}
}