Pointer to the `FILE` stream whose buffering mode is to be set.
2nd Parameter Type : char *
String pointer (array of characters)
2nd Parameter
Pointer to a user-provided buffer for the stream. If `buffer` is `NULL`, the stream will be set to unbuffered mode.
Read more about parameters of setbuf in parameters section
The setbuffunction in C language Sets the buffer to be used by the stream for I/O operations.
The setbuf function is used to associate a buffer with a stream or to disable buffering. If the buffer is NULL, buffering is disabled. Otherwise, the buffer must have a size of at least BUFSIZ bytes, where BUFSIZ is a macro constant defined in <stdio.h>.
The setbuffunction takes 2
parameters:
•
FILE * `stream`: Pointer to the `FILE` stream whose buffering mode is to be set.
•
char * `buffer`: Pointer to a user-provided buffer for the stream. If `buffer` is `NULL`, the stream will be set to unbuffered mode.
Sets the buffering mode for the specified `FILE` stream. If `buffer` is `NULL`, the stream is unbuffered. Otherwise, the stream will use the provided buffer for I/O. The size of the buffer must be at least `BUFSIZ` bytes. This function should be called before any other operations on the stream.
The setbuf function return value :
This function does not return a value
Output
This example demonstrates how to set a custom buffer for a file stream using setbuf.