Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the basic functions in zlib

Shulou Source: shulou.com Published: 2022-06-03 05:54:28 09月29日 Update

What are the basic functions in zlib? I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Get version function: zlibVersion

Compression functions: deflateInit, deflate, deflateEnd

Decompression functions: inflateInit, inflate, inflateEnd

# include # include using namespace std;#define CHUNK 16384int def (FILE * source, FILE * dest, int level) {z_stream strm; strm.zalloc = Z null; strm.zfree = Z null; strm.opaque = Z null; deflateInit (& strm, level); int flush; int have; unsigned char in [CHUNK]; unsigned char out [CHUNK] Do {strm.avail_in = fread (in, 1, CHUNK, source); strm.next_in = in; flush = feof (source)? Z_FINISH: Zhuan NOAA flush; do {strm.avail_out = CHUNK; strm.next_out = out; deflate (& strm, flush); have = CHUNK-strm.avail_out Fwrite (out, 1, have, dest);} while (0 = = strm.avail_out);} while (Z_FINISH! = flush); deflateEnd (& strm); return Zero OK;} int inf (FILE * source, FILE * dest) {z_stream strm; strm.zalloc = Zero null; strm.zfree = Z_NULL Strm.opaque = Zero null; inflateInit (& strm); int ret = Zambiok; int have; unsigned char in [CHUNK]; unsigned char out [CHUNK]; do {strm.avail_in = fread (in, 1, CHUNK, source); strm.next_in = in If (0 = = strm.avail_in) break; do {strm.avail_out = CHUNK; strm.next_out = out; ret = inflate (& strm, Z_NO_FLUSH) Have = CHUNK-strm.avail_out; fwrite (out, 1, have, dest);} while (0 = = strm.avail_out);} while (Z_STREAM_END! = ret); inflateEnd (& strm); return Zerook;} void main (int argc, char * argv []) {cout

Tags: Functions code content methods more problems nothing to do for this reason reasons parameters this skills versions examples articles experience industry information channels errors Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft macOS Redmi Shulou Technology Docker