zlib中基本函數(shù)都有哪些,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
站在用戶的角度思考問題,與客戶深入溝通,找到成安網(wǎng)站設(shè)計與成安網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站設(shè)計制作、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、申請域名、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋成安地區(qū)。獲取版本函數(shù):zlibVersion
壓縮函數(shù):deflateInit、deflate、deflateEnd
解壓縮函數(shù):inflateInit、inflate、inflateEnd
#include#include #include #include using namespace std; #define CHUNK 16384 int 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 : Z_NO_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 Z_OK; } int inf(FILE *source, FILE *dest) { z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; inflateInit(&strm); int ret = Z_OK; 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 Z_OK; } void main(int argc, char *argv[]) { cout<<"zlibVersion:"< 此代碼參數(shù)官網(wǎng)示例代碼,本代碼為了學習,只寫了最簡單的函數(shù),沒有錯誤處理。
看完上述內(nèi)容,你們掌握zlib中基本函數(shù)都有哪些的方法了嗎?如果還想學到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
本文名稱:zlib中基本函數(shù)都有哪些-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://weahome.cn/article/ghcep.html