setbuf function(Set Buffer) in C Language – example and detail

In the C Programming Language, the setbuf characteristic lets you change the way a stream is buffered and to control the size and region of the buffer. The setbuf feature assumes default values for the buffering mode and buffer size.

If buf is no longer a null pointer, the setbuf characteristic will function the equivalent to the setvbuf feature as:

(void) setvbuf(stream, buf, _IOFBF, BUFSIZ);

If buf is a null pointer, the setbuf characteristic will function the equal to the setvbuf feature as:

(void) setvbuf(stream, NULL, _IONBF, 0);

Syntax

The syntax for the setbuf feature in the C Language is:

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

Parameters or Arguments

stream The flow to modify. buf A pointer to the preferred buffer.

Returns

The setbuf function returns zero if successful or a nonzero price if an error used to be encountered.

Required Header

In the C Language, the required header for the setbuf feature is:

#include <stdio.h>

Applies To

In the C Language, the setbuf characteristic can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are similar to the setbuf function:

setvbuf function <stdio.h>

See Also

Other C functions that are noteworthy when dealing with the setbuf function:

fopen function freopen characteristic fflush characteristic