SETBUF(3S)                                             SETBUF(3S)

          setbuf - assign buffering to a stream

          #include <stdio.h>

          setbuf(stream, buf)
          FILE *stream;
          unsigned char *buf;

          Setbuf is used after a stream has been opened but before it
          is read or written.  It causes the character array buf to be
          used instead of an automatically allocated buffer.  If buf
          is the constant pointer NULL, input/output will be com-
          pletely unbuffered.

          A manifest constant BUFSIZ tells how big an array is needed:

               unsigned char buf[BUFSIZ];

          A buffer is normally obtained from malloc(3) upon the first
          getc or putc(3) on the file, except that the standard output
          is line buffered when directed to a terminal.  Other output
          streams directed to terminals, and the standard error stream
          stderr are normally not buffered.  If the standard output is
          line buffered, then it is flushed each time data is read
          from the standard input by read(2).

          fopen(3), getc(3), putc(3), malloc(3)