#include stdio.h>
! p, v- M- I% ]& k5 L. I#include "zlib.h"
+ h* c/ C+ B) ^int main()
5 ~0 A, q/ U" j, E; u{' N; ]- |& n$ ^- o. X
//原始数据
: V5 ]$ X) i; z0 W! ] const unsigned char strSrc[]="hello chinaavg!\\n\\4 m( V! [/ x1 ~% c! }
AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\
, a7 z( p/ h$ I: P: twww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\
' M. x; i; E# g, }& c1 a0 q) awww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\+ K* f6 H7 m6 M0 N$ R+ E5 A
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";% n) r0 n, v9 Y; c$ N" b1 O( B
unsigned char buf[1024]={0},strDst[1024]={0};( a1 y0 ~4 d r J1 q
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);- ?6 I2 s* O/ r7 T
printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen);" U! T, l9 T4 z/ |+ ~# R& @# m5 f
//压缩
7 P+ w3 I: v1 |+ m) p compress(buf,&bufLen,strSrc,srcLen);
0 E5 o9 U3 F; j+ o* o printf("\\nAfter Compressed Length:%d\\n",bufLen);8 c2 k; }$ ]$ d2 i& f8 y
printf("Compressed String:%s\\n",buf);
! c3 m( ]9 \5 f# ^$ n& p //解压缩
1 O: ^) v: `( B uncompress(strDst,&dstLen,buf,bufLen);
* r; V5 X5 v! N& \) U: M/ v printf("\\nAfter UnCompressed Length:%d\\n",dstLen);7 q% ^: o" I4 S
printf("UnCompressed String:%s\\n",strDst);. ]. W6 D5 U/ s3 H
return 0;
) l8 P. ?. o" j- R: j+ S7 s0 I} |