C Language: setvbuf function(Set Buffer)

In the C Programming Language, the setvbuf function lets you change the way a stream is buffered and to control the size and location of the buffer.


The syntax for the setvbuf function in the C Language is:

int setvbuf(FILE  *stream, char *buf, int mode, size_t size);

Parameters or Arguments


The stream to modify.


A pointer to the desired buffer.


It is one of the following:

Mode Explanation
_IOFBF Full buffering
_IOLBF Line buffering
_IONBF No buffering


The number of bytes in the buffer.


The setvbuf function returns zero if successful or a nonzero value if an error was encountered.

Required Header

In the C Language, the required header for the setvbuf function is:

#include <stdio.h>

Applies To

In the C Language, the setvbuf function can be used in the following versions:

  • ANSI/ISO 9899-1990

stdio.h Functions