#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <zlib.h> int main () { setmode(0, _O_BINARY); setmode(1, _O_BINARY); uLongf compressedBytes = 0; uLongf unCompressedBytes = 0; // read data size fread(&compressedBytes , sizeof(uLongf), 1, stdin); fread(&unCompressedBytes, sizeof(uLongf), 1, stdin); // allocate data container Bytef *compressedData = (Bytef*) malloc(compressedBytes); Bytef *unCompressedData = (Bytef*) malloc(unCompressedBytes); // read compressed data fread(compressedData, compressedBytes, 1, stdin); // decompress uncompress(unCompressedData, &unCompressedBytes, compressedData, compressedBytes); // write un-compressed data fwrite(unCompressedData, unCompressedBytes, 1, stdout); fflush(stdout); free(compressedData); free(unCompressedData); return 0; }