野百合也有春天

导航

zlib 用法

#include "zlib.h" 

int _tmain(int argc, _TCHAR* argv[])
{
    //原始数据
    const unsigned char strSrc[]="0.3266555f232662236 6523333";
    unsigned char buf[1024]={0},strDst[1024]={0};
    unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buf),dstLen=sizeof(strDst);
    printf("源字符串:%s\nLength:%d\n",strSrc,srcLen);
    //压缩
    compress2(buf,&bufLen,strSrc,srcLen,3);
    printf("\n压缩后长度:%d\n",bufLen);
    printf("压缩后字符串:%s\n",buf);
    //解压缩
    uncompress(strDst,&dstLen,buf,bufLen);
    printf("\n解压缩长度:%d\n",dstLen);
    printf("解压缩后字符串:%s\n",strDst); 

    return 0;
}

posted on 2010-11-28 22:35  flydream  阅读(417)  评论(0编辑  收藏  举报