C Programming Tutorial
In the C Programming Language, the setbuf function lets you change the way a stream is buffered and to control the size and location of the buffer. The setbuf function assumes default values for the buffering mode and buffer size.
If buf is not a null pointer, the setbuf function will perform the equivalent to the setvbuf function as:
(void) setvbuf(stream, buf, _IOFBF, BUFSIZ);
If buf is a null pointer, the setbuf function will perform the equivalent to the setvbuf function as:
(void) setvbuf(stream, NULL, _IONBF, 0);
Syntax
The syntax for the setbuf function in the C Language is:
void setbuf(FILE *stream, char *buf);
Parameters or Arguments
stream
The stream to modify.
buf
A pointer to the desired buffer.
Returns
The setbuf 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 setbuf function is:
#include <stdio.h>
Applies To
In the C Language, the setbuf function can be used in the following versions:
- ANSI/ISO 9899-1990