setvbuf

Full prototype:

int setvbuf(FILE* restrict, char* restrict, int, size_t);  

Purpose and Notes:

Used to define how a stream should be buffered. The stream associated with the FILE* passed in as the first argument should be buffered according to the third argument's "mode" which is one of three predefined options given to you as macros from <stdio.h>. (Look at argument three below)

Returns:

int- Returns zero on success and a nonzero value if unsuccessful.

Argument 1:

FILE* restrict- A FILE* associated to the stream in which you want to set the type of buffering for.

Argument 2:

char* restrict- A charcter array buffer you want to use for the buffering of the stream associated with the FILE* passed in as the first argument. If you want the function to automatically allocate a buffer then this argument should be NULL.

Argument 3:

int- The "mode" or type of buffering you want to set for the stream associated with the FILE* passed in as the first argument. Three modes are defined by the standard using macros provided by the <stdio.h> header. They are:
_IOFBFFull buffering.
_IOLBFLine buffering.
_IONBFNo buffering.


Argument 4:

size_t- In the case you provide a value other than NULL as the second argument and thus provided a buffer as the second argument to the function then ths argument will set the sizeof that buffer for buffering. Otherwise its implementation defined whether or not setvbuf() will use this size for its own internal buffer if you provided NULL as the second argument.

Example 1
  1    FILLER SOURCE CODE
FILLER TERMINAL