#include stdio.h>
3 Y+ }3 d' N% Z#include "zlib.h"$ ^- A' u" Q9 O, v1 g. x5 [, ^: I
int main()
3 @6 g* Q* x) P) |{* x) `, m, c/ R
//原始数据. b; \3 `0 [+ r8 q! _! Y& \: G
const unsigned char strSrc[]="hello chinaavg!\\n\\
0 r, @: U& u' v) r/ f T0 `$ D; DAVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\
# O9 [8 O5 L0 g% J1 W2 A0 W( D jwww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\* h+ p* e( |$ B' \1 d
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\6 J" \8 C+ o2 [! Z) `' v6 E" X
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";% n7 t0 R( G* Y+ x
unsigned char buf[1024]={0},strDst[1024]={0}; Z1 D0 Q+ u! X# g
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);: G6 h& {; Z, C% T
printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen);
2 f4 |4 l' z7 g* z; ? //压缩# l# R6 k" K" n9 C4 t$ b9 T
compress(buf,&bufLen,strSrc,srcLen);6 p: \! n0 T" | H' Z
printf("\\nAfter Compressed Length:%d\\n",bufLen);
0 x. \& R- j- A- m. q2 | printf("Compressed String:%s\\n",buf);) T0 r1 k% R! N: O, A/ a
//解压缩+ k& d/ o8 B" G9 K, _# S e' P
uncompress(strDst,&dstLen,buf,bufLen);/ r" i' E9 V+ u! A/ x
printf("\\nAfter UnCompressed Length:%d\\n",dstLen);
3 k9 |( X8 Q3 Z' T) s' Q: G0 r printf("UnCompressed String:%s\\n",strDst);# {/ _5 p0 ~6 S2 q: J+ j4 x
return 0;
/ E4 B: T# ~5 _9 R} |