Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Primary application of zlib

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Download the latest code here. I downloaded zlib-1.2.5.tar.gz.

After decompressing, enter the zlib-1.2.5 folder, and then use the following command to generate the library file

. / configure

Make

Libz.a will be generated after that

Edit the following test code in this directory

# include#include#include#include "zlib.h" int main () {unsigned char uncomp_bytes; uLong uncomp_size;uLong return_code=0;unsigned char comp_bytes; uLong comp_size=100;strcpy (uncomp_bytes, "helloworld"); uncomp_size=strlen (uncomp_bytes); printf ("uncomp_size:%d\ n", uncomp_size) If ((return_code = compress ((Byte *) comp_bytes,&comp_size, (Byte *) uncomp_bytes,uncomp_size))! = Z_OK) {printf ("return code:%d\ n", return_code); exit (1);} printf ("comp_size:%d\ n", comp_size); uncomp_size=100 If ((return_code=uncompress ((Byte *) uncomp_bytes,&uncomp_size, (Byte *) comp_bytes,comp_size))! = Z_OK) {printf ("return code:%d\ n", return_code); exit (1);} printf ("uncomp_size:%d\ n", uncomp_size); printf ("% s\ n", uncomp_bytes); return 0;}

Use the command:

Gcc test.c-o test-lz

The output is as follows:

Uncomp_size:10comp_size:18uncomp_size:10helloworld

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report