#include stdio.h>8 c7 k5 X6 g4 G5 z, {! x J5 y
#include "zlib.h"
1 A+ H" ?/ Q9 @% K; B5 @int main()
- Y* ]6 I1 ], J2 e7 G. k8 R( k{$ \2 @& `$ y; d, K0 ?
//原始数据
( t* O+ T3 U. W6 } const unsigned char strSrc[]="hello chinaavg!\\n\\
: W( m& C1 o0 l) j& [, S% v! DAVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\- |; D1 w6 ~5 M, M" B
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\* Z9 X7 i( M# x
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\9 c& r8 u+ k& T
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";
6 V5 t/ A. U& F/ N0 f2 \8 H unsigned char buf[1024]={0},strDst[1024]={0};; u9 Q- x5 }4 Q- _9 ~
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);
4 I) w3 U9 r9 Q printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen);
) c6 R/ b3 s: C, M! M: t* \! C //压缩4 i5 ?& ` ~1 o3 f7 {
compress(buf,&bufLen,strSrc,srcLen); H/ S6 f( q! D7 {' P2 c
printf("\\nAfter Compressed Length:%d\\n",bufLen);
- H7 l+ |+ M, O9 e+ w printf("Compressed String:%s\\n",buf);
9 I2 z s& j% c //解压缩% d9 z' A; q& l/ s& S( H4 I/ U8 J% I& H
uncompress(strDst,&dstLen,buf,bufLen);
* ?; A# ~, o$ [6 g" e printf("\\nAfter UnCompressed Length:%d\\n",dstLen);
2 T1 A3 B8 L, `) z& N printf("UnCompressed String:%s\\n",strDst);6 E! g2 x" ` @( f
return 0;
& E) e6 P# C L+ q! s} |