#include stdio.h>2 ?. Y# `. S9 A0 C+ q# p S3 m9 d
#include "zlib.h"
' C8 y( y# b9 Rint main()/ J/ }$ T4 Z! [! f
{4 f. _7 A- p2 y) l# U/ A
//原始数据
* z4 o6 R' K6 a2 x6 p7 g const unsigned char strSrc[]="hello chinaavg!\\n\\+ E6 x7 g5 R% h% F e
AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\6 `3 |! l0 g9 O7 ?% _6 m
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\
# S/ Q& g& w. c2 I5 Owww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\) Q* y/ t3 l% B. x# f
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";* S/ o! G8 D. \" S" ~$ o3 K( N
unsigned char buf[1024]={0},strDst[1024]={0};
& |& l: c9 m5 L unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);+ c; F& b. S" ?7 ?6 e+ N3 Q6 e
printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen);- o5 X4 U& D6 C \+ P. I. U
//压缩
' n0 o3 O3 Z. r+ j0 z compress(buf,&bufLen,strSrc,srcLen);
1 O5 m% R& n' ]! [3 \: w printf("\\nAfter Compressed Length:%d\\n",bufLen);: s. `. m7 ^1 |. a( w) F+ g/ j
printf("Compressed String:%s\\n",buf);
7 d7 s& j: Q+ v4 x/ X3 I6 X: @ //解压缩/ O7 m" s! T8 `2 `% z# r
uncompress(strDst,&dstLen,buf,bufLen);
E3 o% r4 H" ]* M printf("\\nAfter UnCompressed Length:%d\\n",dstLen);4 C* E) n5 Y7 Q# @+ y s
printf("UnCompressed String:%s\\n",strDst);
* i0 ]! w0 H5 @' C) P5 M return 0;
2 z( U# T* r; [" M) g t} |