setvbuf(3C)
_________________________________________________________________
setvbuf function
Assign a buffer to a specified file.
_________________________________________________________________
Calling Sequence
#include <stdio.h>
int setvbuf();
FILE *fp;
char *buf;
int type, size, err;
err = setvbuf(fp, buf, type, size);
where buf points to the array to be used for buffering.
If it is a null pointer, the buffer will be
automatically allocated.
type determines how the file will be buffered.
size specifies the size of the buffer to be used.
Description
Use the setvbuf function to assign buffering for a specified
file. You can use it after a file is open, but before it is read
from or written to. The type value specifies how the file will
be buffered. The following are valid options for type:
Option Specifies
_IOFBF Fully-buffered input and output.
_IOLBF Line-buffered output. The buffer is flushed
whenever a New Line occurs, or the buffer is
full, or input is requested.
_IONBF Unbuffered input and output.
If input and output are unbuffered, setvbuf ignores buf and size.
The constant BUFSIZ, defined in stdio.h, is often a good size to
use.
By default, output to a terminal is line-buffered; all other
input and output is fully-buffered.
NOTE: If you allocate buffer space as an automatic variable in a
code block, be sure to close the stream in the same block before
returning.
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
setvbuf(3C)
Returns
If you specify an invalid value for type or size, setvbuf will
return a non-zero. Otherwise, it will return zero.
Related Functions
See also the fopen, getc, malloc, putc, and setbuf functions.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)