#include #include #include #include #include struct exited { ~exited() { std::cout << "dtors finished"; } }; int main(int argc, char** argv) { exited x; if (argc < 3) { std::cout << "Usage: " << argv[0] << " file bytes\n"; return 1; } std::ofstream ofs(argv[1], std::ios_base::binary); boost::iostreams::filtering_stream filter; filter.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip_params())); filter.push(ofs); int bytes = atoi(argv[2]); char *data = new char[bytes]; srand(0); //fill with random data that won't get gzipped to a few bytes for (int i = 0; i < bytes - 1; ++i) { data[i] = rand() % 254 + 1; } data[bytes - 1] = 0; filter << data; delete[] data; std::cout << "main ended "; }