当前位置: 首页 > news >正文

做网站游戏总结的例文黄陂建设网站

做网站游戏总结的例文,黄陂建设网站,创意图案设计网站,怎样是做网站前言 新建项目:pro文件中新增代码 LIBS -lz 在main.cpp函数中#include "zlib.h",如果此时运行代码提示没有找到对应的函数,那么就qt安装目录:D:\C\qt5.12.7\Tools\mingw730_64\x86_64-w64-mingw32\include(这里是博主…

前言

 新建项目:pro文件中新增代码

LIBS+= -lz

在main.cpp函数中#include "zlib.h",如果此时运行代码提示没有找到对应的函数,那么就qt安装目录:D:\C++\qt5.12.7\Tools\mingw730_64\x86_64-w64-mingw32\include(这里是博主的路径,作为参考找自己的路径)下查看是否有zlib.h头文件,复制这个文件到当前目录下即可运行

数据流压缩解压缩


#include "zlib.h"
#include <zlib.h>int main(int argc,char * argv[])
{
//    QApplication a(argc, argv);char text[] = "zlib compress and uncompress test\nturingo@163.com\n2012-11-05\n";uLong tlen = strlen(text) + 1;	/* 需要把字符串的结束符'\0'也一并处理 */char* buf = NULL;uLong blen;cout <<"start: tlen = "<< tlen << endl;/* 计算缓冲区大小,并为其分配内存 */blen = compressBound(tlen);	/* 压缩后的长度是不会超过blen的 */if((buf = (char*)malloc(sizeof(char) * blen)) == NULL){printf("no enough memory!\n");return -1;}cout << "compressBound: blen =  " << blen<< endl;
//        /* 压缩 */if(compress((Bytef*)buf, &blen,(Bytef*) text, tlen) != Z_OK){printf("compress failed!\n");return -1;}cout <<"compress \n";cout << strlen(buf)+1 << endl;cout <<"uncompress \n";/* 解压缩 */if(uncompress((Bytef*)text, &tlen, (Bytef*)buf, blen) != Z_OK){printf("uncompress failed!\n");return -1;}/* 打印结果,并释放内存 */printf("%s", text);if(buf != NULL){free(buf);buf = NULL;}//    return a.exec();return 0;
}
   char text[] = "zlib testddsa ";uLong tlen = strlen(text) + 1;	/* 需要把字符串的结束符'\0'也一并处理 */char* buf = NULL;uLong blen;cout <<"start: tlen = "<< tlen << endl;/* 计算缓冲区大小,并为其分配内存 */blen = compressBound(tlen);	/* 压缩后的长度是不会超过blen的 */if((buf = (char*)malloc(sizeof(char) * blen)) == NULL){printf("no enough memory!\n");return -1;}cout << "blen = " << blen<< endl;compress((Bytef*)buf,&blen,(Bytef*)text,tlen);cout << "blen = "<< blen<< endl;cout << "strlen(buf) = " << strlen(buf)<< endl;uLong ubound = compressBound(strlen(buf)+1 );/* 压缩后的长度是不会超过blen的 */cout << "bound =" << ubound<< endl;uncompress((Bytef*)text,&ubound,(Bytef*)buf,blen);cout << "unbound =" << ubound<< endl;

文件压缩解压缩

        uLong blen,tlen;char text[1024];char* dest;FILE* f,ff;
//        f = fopen("test.txt","r+");//        fread(text,1,1024,f);
//        tlen = strlen(text)+1;
//        cout << text << endl;
//        cout << "tlen = "<< tlen  << endl;//        blen = compressBound(tlen);
//        cout << "blen = "<< blen  << endl;//        dest = (char *)malloc(blen );
//        compress((Bytef*)dest,&blen,(Bytef*)text,tlen);//        cout << "blen = "<< blen  << endl;
//        ff = fopen("test.aaa","w");
//        fwrite(dest,blen,1,ff);
//        fclose(ff);
//        fclose(f);f= fopen("test.aaa","r+");fread(dest,1024,1,f);fclose(f);
//            cout << dest << endl;blen = compressBound(strlen(dest)+1);uncompress((Bytef*)text,&blen,(Bytef*)dest,1024);cout << text << endl;

http://www.sczhlp.com/news/139890/

相关文章:

  • 谁给个网站啊急急急2021有什么网站可以做简历
  • 注册域名建设网站wordpress sora 下载
  • 网站服务器如何做端口映射我国大宗商品交易所
  • app公司网站建设价格郑州门户网站建设
  • 弱结构光三维扫描重建
  • 9.27 git与pycharm
  • 网站建设维护书做我的世界的mod的网站
  • 正规的锦州网站建设做家装的网站好
  • 杭州房地产网站建设苏州公司官网制作
  • 天蝎网站推广优化泰安平台公司
  • 中关村哪里可以做网站wordpress门户网站主题
  • 数字货币众筹网站开发提供网站建设工具的品牌有哪些
  • 中国的网站为什么要备案滇中引水工程建设管理局网站
  • 以前做的网站怎么才能登陆后台影院禁止18岁以下观众入内
  • 江西建网站做优化企业客户信息管理系统
  • 成都专业做网站南京seo外包平台
  • 网站开发费用成本表ppt要怎么做网站
  • pc门户网站是什么意思怎么看一个网站用什么语言做的
  • 怎么优化网站代码seo企业网站优化
  • 网站问责建设书网站建设怎么选公司
  • 揭阳企业网站排名多少钱模板网生产线
  • 河南经天路桥建设总公司网站不锈钢网架公司
  • 深圳网站外包公司简介成都网站设计服务商
  • 阿里云服务器 多个网站基金会网站建设
  • 企业网站建设长沙网站搜索推广方案论文
  • 怎样添加网站上百度商桥代码WordPress seo终极优化
  • 网站和平台是一个意思吗建筑设计前景怎么样
  • 沛县做网站视觉设计和平面设计的区别
  • 捷克cz公司网站网站建设中颜色的感染力
  • 钦州建站哪家好做网站模板链接放哪里