|
NAMEsetbuf , setbuffer ,
setlinebuf , setvbuf —
stream buffering operations
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <stdio.h>
void
void
int
int
DESCRIPTIONThe three types of buffering available are unbuffered, block buffered, and line buffered. When an output stream is unbuffered, information appears on the destination file or terminal as soon as written; when it is block buffered many characters are saved up and written as a block; when it is line buffered characters are saved up until a newline is output or input is read from any stream attached to a terminal device (typicallystdin ). The function
fflush(3)
may be used to force the block out early. (See
fclose(3).)
Normally all files are block buffered. When the first I/O
operation occurs on a file,
malloc(3)
is called, and an optimally-sized buffer is obtained. If a stream refers to
a terminal (as The The size argument may be given as zero to
obtain deferred optimal-size buffer allocation as usual. If it is not zero,
then except for unbuffered files, the buf argument
should point to a buffer at least size bytes long;
this buffer will be used instead of the current buffer. If
buf is not The The other three calls are, in effect, simply aliases for calls to
setvbuf(stream, buf, buf ? _IOFBF :
_IONBF, BUFSIZ); The setvbuf(stream, (char *)NULL, _IOLBF,
0); RETURN VALUESThesetvbuf () function returns 0 on success, or
EOF if the request cannot be honored (note that the
stream is still functional in this case).
The SEE ALSOstdbuf(1), fclose(3), fopen(3), fread(3), malloc(3), printf(3), puts(3)STANDARDSThesetbuf () and setvbuf ()
functions conform to ISO/IEC 9899:1990
(“ISO C90”).
HISTORYThesetbuf () function first appeared in
Version 7 AT&T UNIX. The
setbuffer () function first appeared in
4.1cBSD. The setlinebuf ()
function first appeared in 4.2BSD. The
setvbuf () function first appeared in
4.4BSD.
BUGSsetbuf () usually uses a suboptimal buffer size and
should be avoided.
Visit the GSP FreeBSD Man Page Interface. |