#include stdio.h>$ R/ j( F3 n7 C3 U& b- H. E
#include "zlib.h", p- B, F" V/ I' @5 G% R
int main()& H9 n: c9 R+ ], }
{
! s }4 K) U* k( c1 ^ //原始数据
3 Z5 `! F" B6 f8 k# `" y+ o! E const unsigned char strSrc[]="hello chinaavg!\\n\\/ }$ V$ |1 D& F. O$ Q9 ~
AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\
+ s2 K9 z* y' f/ g* a: M0 x& Bwww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\( x4 i5 e1 ^, U* E9 X: h, Q
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\2 V: R/ _6 v, s, H/ F5 ?
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";
7 J- @( P( a4 U' b0 R unsigned char buf[1024]={0},strDst[1024]={0};/ R9 b+ T' p' H% y
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);+ O0 W" d2 T- K* C3 }
printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen);
4 [& ]4 S' h* \ t //压缩/ z- k/ T9 R: k, q
compress(buf,&bufLen,strSrc,srcLen);* a6 |, A* Q; y- n
printf("\\nAfter Compressed Length:%d\\n",bufLen);. ] J4 y1 m- A# R
printf("Compressed String:%s\\n",buf);, f6 ~% k: l( M$ v5 ^) c ?
//解压缩0 A& f, e. U# @3 ^$ x7 P" V
uncompress(strDst,&dstLen,buf,bufLen);
: P8 r6 E8 N9 ^1 j! J5 L( x printf("\\nAfter UnCompressed Length:%d\\n",dstLen);1 d7 B: w% X% E
printf("UnCompressed String:%s\\n",strDst);) K3 t$ @% e7 q
return 0;
+ H2 ~' y* U& ~' [6 }} |