#include stdio.h>
9 ^) W/ j5 o* A) j9 Q7 B& q% s#include "zlib.h", r3 c8 e I4 B1 o; X
int main()
! \* v9 g) t p9 ]6 T. |{& Z% F7 ?: r' h% R
//原始数据 S, L# V4 T( u7 e* m) i
const unsigned char strSrc[]="hello chinaavg!\\n\\6 o4 [, f2 O7 e6 J Q* V2 V* ~' g
AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试 AVG测试\\
# v0 Q0 h# S! y; awww.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\
2 t/ k( d8 p7 F A/ ]www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com\\1 l% I& u. J0 F+ T/ c9 a/ B t
www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com www.chinaavg.com";+ f1 }3 k2 t% ?) `5 p7 a2 G
unsigned char buf[1024]={0},strDst[1024]={0};
5 ]% z6 a% z, p! T unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);
5 J$ ^( Y- q' ]8 | printf("Src string:%s\\nLength:%d\\n",strSrc,srcLen);7 n; ?! a" ?6 F& A
//压缩5 @; G7 {, j2 v0 Y9 W8 ~: h
compress(buf,&bufLen,strSrc,srcLen);
5 _6 m. _ ]6 j. X! n8 P printf("\\nAfter Compressed Length:%d\\n",bufLen);' N8 d8 Z8 c1 u6 ]1 x9 t) V! e W
printf("Compressed String:%s\\n",buf);* m' y6 P" _! l1 h ^
//解压缩, y- |- ^6 l4 M
uncompress(strDst,&dstLen,buf,bufLen);2 F6 n$ T/ }; B2 \6 v
printf("\\nAfter UnCompressed Length:%d\\n",dstLen);3 a Z: c' ?0 B( P3 Q6 W" L; b5 [
printf("UnCompressed String:%s\\n",strDst); |. E) F2 Y( g& Z. K' M1 z8 v
return 0;" S1 k4 K ~* |$ L
} |