#include "zfstream.h" int main() { // Construct a stream object with this filebuffer. Anything sent // to this stream will go to standard out. gzofstream os( 1, ios::out ); // This text is getting compressed and sent to stdout. // To prove this, run 'test | zcat'. // setcompressionlevel(os, Z_NO_COMPRESSION ); os << "Hello, Mommy" << endl; os << "How about a number? " << 17 << endl; // setcompressionlevel(os, Z_DEFAULT_COMPRESSION ); os << "I'm compressing again" << endl; os << "hello, hello, hi, ho!" << endl; os.close(); gzofstream os2("test.out2.gz"); os2 << "This is a test of gzofstream and gzifstream.\n"; os2.close(); gzifstream i2("test.out2.gz"); ofstream o3("test2.out.echo"); char c; for (i2>> c; !i2.eof(); i2>>c) { o3 << c; } i2.close(); o3.close(); for (int i=0; i<19; i++) { cerr << " " << i << flush; gzifstream * i3 = new gzifstream("test.out2.gz"); cerr << " open" << flush; for ((*i3)>> c; ! i3->eof(); (*i3)>>c) {} cerr << " read" << flush; i3->close(); cerr << " closed\n" << flush; delete i3; } cout << "\n"; return 0; }