Home > Electronics Tutorials > C Language Tutorial > stdio.h - File Functions - setvbuf

C Language Programming Library Reference Guide

stdio.h - File Functions - setvbuf

Declaration:

int setvbuf(FILE *stream, char *buffer, int mode, size_t size); Defines how a stream should be buffered. This should be called after the stream has been opened but before any operation has been done on the stream. The argument mode defines how the stream should be buffered as follows:
 
_IOFBF Input and output is fully buffered. If the buffer is empty, an input operation attempts to fill the buffer. On output the buffer will be completely filled before any information is written to the file (or the stream is closed).
_IOLBF Input and output is line buffered. If the buffer is empty, an input operation attempts to fill the buffer. On output the buffer will be flushed whenever a newline character is written.
_IONBF Input and output is not buffered. No buffering is performed.

The argument buffer points to an array to be used as the buffer. If buffer is a null pointer, then setvbuf uses malloc to create its own buffer.

The argument size determines the size of the array.

On success zero is returned. On error a nonzero value is returned.

Note: To report broken links or to submit your projects, tutorials please email to Webmaster

Discover

     more......