#include <stdio.h>
void setbuf(FILE *stream, char *buf);
int setvbuf(FILE *stream, char *buf, int type, size_t size);
MT-Safe
char buf[BUFSIZ ];
setvbuf() may be used after a stream has been opened but before it is read or written. type determines how stream will be buffered. Legal values for type (defined in <stdio.h>) are:
If buf is not the NULL pointer, the array it points to will be used for buffering, instead of an automatically allocated buffer. size specifies the size of the buffer to be used. If input/output is unbuffered, buf and size are ignored.
For a further discussion of buffering, see stdio(3S) .
When using setbuf(), buf should always be sized using BUFSIZ . If the array pointed to by buf is larger than BUFSIZ , a portion of buf will not be used. If buf is smaller than BUFSIZ , other memory may be unexpectedly overwritten.
Parts of buf will be used for internal bookkeeping of the stream and, therefore, buf will contain less than size bytes when full. It is recommended that stdio(3S) be used to handle buffer allocation when using setvbuf().