Introduction to Linux programming-Application of zlib
Source: Internet
Author: User
Introduction to Linux programming-Use of zlib-general Linux technology-Linux programming and kernel information. For details, see the following. Introduction to Linux programming-Application of zlib
The gzip (*. gz) file format is almost the standard format in Linux. Some people think that the compression ratio of bzip2
Gzip is high. This statement is generally correct, but according to my personal experience, half of it
For the above files, bzip2 does not have a higher compression ratio than gzip. In a few cases, the gzip compression ratio is reversed.
It is higher than bzip2.
Zlib is a function library that supports gzip file formats. It makes access to the gz file as if it were an open file.
Easily, you can easily add gz support for your program.
Example: showgz. c
# Include
# Include
# Include
Void main (int argc, char ** argv)
{
GzFile zip;
Int c;
If (argc <2) return;
Zip = gzopen (argv [1], "rb ");
While (c = gzgetc (zip ))! = EOF) putchar (c );
Gzclose (zip );
}
Compile
Gcc-o showgz. c-lz
Inspection
Gzip-9 <showgz. c> showgz.c.gz
./Showgz showgz.c.gz
The program content will be displayed. The function of showgz can be said to be gzip-dc.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.