Opening gzipped files for reading in C without creating temporary files

c, file-io, gzip

Solution

You can use libzlib to open the gzipped files directly.

It also offers a "gzopen" function that behaves similar to fopen but operates on gzipped files. However, fscanf would probably not work on such a handle, since it expects normal FILE pointers.

Problem

I have some gzipped files that I want to read in C via fopen and fscanf. Is there anyway to do this without having to gunzip the files to temporary files? Thanks.

Original source