Everything

setvbuf


Defines and sets a stream input/output buffer area by the user program.

[Format]

#include <stdio.h>

long setvbuf (FILE *fp, char *buf, long type, size_t size);

[Parameters]

fp File pointer

buf Pointer to buffer area

type Buffer management method

size Size of buffer area

[Return values]

Normal: 0

Abnormal: Nonzero

[Remarks]

The setvbuf function defines the storage area pointed to by buf so that it can be used as an input/output buffer area for the stream input/output file indicated by file pointer fp.

There are three ways of using this buffer area, as follows:

(a)

When _IOFBF is specified as type

Input/output is fully buffered.

(b)

When _IOLBF is specified as type

Input/output is line buffered; that is, input/output data is fetched from the buffer area when a new-line character is written, when the buffer area is full, or when input is requested.

(c)

When _IONBF is specified as type

Input/output is unbuffered. The setvbuf function usually returns 0. However, when an illegal value is specified for type or size, or when the request on how to use the buffer could not be accepted, a value other than 0 is returned.

The buffer area must not be released before the open stream input/output file is closed. In addition, the setvbuf function must be used between opening of the stream input/output file and execution of input/output processing.