zlib简单示例compress和uncompress代码

发布时间:2021-10-14 09:39:06 作者:柒染
来源:亿速云 阅读:157

zlib简单示例compress和uncompress代码,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

zlib简单示例代码,compress、uncompress:

#include <iostream>
#include <string>

#include <zlib.h>
#include <zconf.h>

using namespace std;


int main(int argc, char *argv[])
{
	//
	unsigned char szSrc[] = "test the compression and uncompression of zlib.";
	unsigned long nSrcLen = sizeof(szSrc);

	unsigned char szZip[1024] = {0};
	unsigned long nZipLen = 1024;

	compress(szZip, &nZipLen, szSrc, nSrcLen);

	//
	unsigned char szUnZip[1024] = {0};
	unsigned long nUnZipLen = 1024;

	uncompress(szUnZip, &nUnZipLen, szZip, nZipLen);

	//
	cout<<"Src:"<<szSrc<<", len:"<<nSrcLen<<endl;		
	cout<<"Zip:"<<szZip<<", len:"<<nZipLen<<endl;
	cout<<"UnZip:"<<szUnZip<<", len:"<<nUnZipLen<<endl;



	return 0;
}

输出结果:

Src:test the compression and uncompression of zlib., len:48
Zip:x.I-.Q(?UH蜗-(J-.翁?H?Q(??Sㄊ??, len:46
UnZip:test the compression and uncompression of zlib., len:48

关于zlib简单示例compress和uncompress代码问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. 为php 编译zlib
  2. zlib 初级应用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

zlib compress uncompress

上一篇:如何实现数组对象过滤

下一篇:Jquery+JSON+WebService怎么用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》