Buffering

Notes on Buffering


Buffering setvbuf()

We can change the buffering by calling the following function:

    #include <stdio.h>

    /* Returns: 0 if OK, nonzero on error */
    int setvbuf(FILE *fp, char *buf, int mode, size_t size);
    

The setvbuf function must be called after the stream has been opened, but before any other operation is performed on the stream. With setvbufwe specify exactly what type of buffering we want. To enable buffering:

To disable buffering: