Name

gzputs — Writes to a compressed file.


Library

Libz.lib


Synopsis

#include <zlib.h>
int gzputs (gzFile file, const char * s);

Return Value

On success, gzputs() shall return the number of uncompressed bytes actually written to file. On error gzputs() shall return a value less than or equal to 0. Applications may examine the cause using gzerror().


Detailed Description

The gzputs() function shall write the null terminated string s to the compressed file referenced by file, which shall have been opened in a write mode (see gzopen() and gzdopen()). The terminating null character shall not be written. The gzputs() function shall return the number of uncompressed bytes actually written.


Examples

To write the null terminated string s="ello" to the compressed file referenced by file:

#include <stdio.h>
#include <zlib.h>

void Gzputs( )
{
gzFile file;
const char * fname = TESTFILE ;
file = gzopen(fname, "wb");
int x = gzputs(file, "ello");
printf("number of character written is %d",x);
gzclose(file);

}

Output

Number of character written is 4.   

Errors

On error, gzputs() shall set the error number associated with the stream identified by file to indicate the error. Applications should use gzerror() to access this error value. If file is NULL, gzputs() shall return Z_STREAM_ERR.

Z_ERRNO

An underlying base library function has indicated an error. The global variable errno may be examined for further information.

Z_STREAM_ERROR

The stream is invalid, is not open for writing, or is in an invalid state.

Z_BUF_ERROR

no compression progress is possible (see deflate()).

Z_MEM_ERROR

Insufficient memory available to compress.


Feedback

For additional information or queries on this page send feedback

© 2007-2009 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.