![]() |
![]() |
![]() |
![]() |
Assign line buffering to a stream
#include <unix.h> int setlinebuf( FILE *iop );
libc
The setbuffer() and setlinebuf() functions assign buffering to a stream. The types of buffering available are:
The fflush() function may be used to force the block out early. Normally all files are block buffered. A buffer is obtained from malloc() when the first getc() or putc() is performed on the file. If the standard stream stdout refers to a terminal, it's line buffered. The standard stream stderr is unbuffered by default.
The setlinebuf() function is used to change the buffering on a stream from block buffered or unbuffered to line buffered. Unlike setbuffer(), it can be used at any time that the stream iop is active.
A stream can be changed from unbuffered or line buffered to block buffered by using freopen(). A stream can be changed from block buffered or line buffered to unbuffered by using freopen() followed by setbuf() with a buffer argument of NULL.
No useful value.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
fclose(), fflush(), fopen(), fread(), freopen(), getc(), malloc(), printf(), putc(), puts(), setbuf(), setbuffer(), setvbuf()
![]() |
![]() |
![]() |
![]() |