Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

setvbuf - Set input/output buffer

&pagelevel(4)&pagelevel

Definition

#include <stdio.h>

int setvbuf(FILE *fp, char *buffer, int type, size_t n);

setbuf sets up a memory area for the file with the file pointer fp. This memory area is then used instead of the area assigned by the system for buffering the input/output data.

The file pointer fp must point to a file which is already open and for which no read or write functions have yet been performed.

Parameters

FILE *fp

Pointer to the file for which an input/output buffer is to be made available.

char *buffer

Pointer to the area to be used as the buffer or NULL.

If the argument is a NULL pointer, the buffer assigned by the system is used.

int type

Type of buffering for the file. This parameter is checked only syntactically and otherwise ignored. It must contain one of the following predefined values:

_IOFBF (full buffering)
_IOLBF (line buffering)
_IONBF (no buffering, not supported).

The type of buffering is determined by the type of file and cannot be changed by the user:
Text files are line-buffered, i.e. the data is written to the file whenever a newline character (\n) occurs.
Binary files are full-buffered, i.e. the data is written to the file when the buffer is full.
Unbuffered input/output is not supported.

size_t n

size of the buffer area buf.

Return val.

0

if successful.


!= 0

if an invalid value for type was passed or the function cannot be executed.

Note

The pointer buffer must point to an area of size BUFSIZ for a file with default attributes.
BUFSIZ is defined in <stdio.h>.
If the blocking factor is explicitly defined with the BUFFER-LENGTH parameter of the ADD-FILE-LINK command, the size of the area must correspond to this defined blocking size.

See also

setbuf