#include stdio.h>4 T2 p: V* C& T' I$ `7 W" `1 l% z
#include "zlib.h"
& U& u& _$ `) m$ ]0 o& Y9 c# iint main()0 o: r, I1 L, t
{
' W: U- O$ @# S; ~ //原始数据8 J' G8 p5 A' Q0 }3 C1 V
const unsigned char strSrc[]="hello chinaavg!\\n\\
- c; `3 n8 Y' A! |; bAVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\
$ \; }. g/ h) V# hwww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\' v1 s$ f4 T2 d+ r2 z+ n5 K, P p4 I
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\- C8 @2 D" F; \9 B
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";: h1 Q, ]& E8 s( L
unsigned char buf[1024]={0},strDst[1024]={0};$ w& P s/ d" O: S4 ~
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst); a5 E1 v3 D8 _3 w; v& Y g( T1 O4 Q
printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen); A0 I$ V& G% x% y: M
//压缩
$ G5 \5 C7 V" ] compress(buf,&bufLen,strSrc,srcLen);
0 f% y& v- C) i" l8 [: H8 P' Q printf("\\nAfter Compressed Length:%d\\n",bufLen);
* c, i$ y% d/ G printf("Compressed String:%s\\n",buf);
, u/ g- F! H2 F" N //解压缩& b4 @3 \/ V; G
uncompress(strDst,&dstLen,buf,bufLen);
' I1 A, a) P/ k5 X( } h printf("\\nAfter UnCompressed Length:%d\\n",dstLen);" y- U, U: v$ W& t" h1 T5 d; M- Z
printf("UnCompressed String:%s\\n",strDst);
6 Q: N! b0 v& _& ~% |. t7 Q( y, U! o return 0;
$ K; I2 i1 T& Z: C} |