#include <string>
#include <vtk_zlib.h>
static const int LENGTH = 0x1000;
int main(int, char* [])
{
// try opening file
gzFile file = gzopen(file_name, "rb");
if (!file)
{
return EXIT_FAILURE;
}
const int buffer_size = 1024; // 缓冲区大小
char buffer[LENGTH];
std::string content;
int bytes_read;
while ((bytes_read = gzread(file, buffer, buffer_size)) > 0) {
content.append(buffer, bytes_read);
}
gzclose(file);
return EXIT_SUCCESS;
}
VTK已经自带zlib库,如果想用zlib的功能可以直接引入vtk_zlib.h头文件进行使用
文章评论