gzgets -- read a string from a compressed file


#include <zlib.h>

char * gzgets (gzFile file, char * buf, int len);


The gzgets() function shall attempt to read data from the compressed file stream file, uncompressing it into buf until either len-1 bytes have been inserted into buf, or until a newline character has been uncompressed into buf. A null byte shall be appended to the uncompressed data. The file shall have been opened in for reading (see gzopen() and gzdopen()).

Return Value

On success, gzgets() shall return a pointer to buf. Otherwise, gzgets() shall return Z_NULL. Applications may examine the cause using gzerror().


On error, gzgets() shall return Z_NULL. The following conditions shall always be treated as an error:

file is NULL, or does not refer to a file open for reading;
buf is NULL;
len is less than or equal to zero.