Function setbuf () in C
The function void setbuf (FILE * stream, char * buffer) in the standard C Library defines how a Stream is buffered. This function should be called once the file attached to the Stream has been opened, but before any input or output operation has taken place.
Declare setbuf () function in C
Below is the declaration for the setbuf () function in C:
void setbuf ( FILE * stream , char * buffer )
Parameters
stream - This is the pointer to a FILE object that identifies the opened stream.
buffer - This is the buffer that has been allocated. It should be at least BUFSIZ bytes in length, which is a macro constant to be used as the length of this array.
Returns the value
This function does not return any values.
For example
The following program C illustrates the usage of the setbuf () function in C:
#include int main () { char buf [ BUFSIZ ]; setbuf ( stdout , buf ); puts ( "Hoc C co ban tai QTM !!!" ); fflush ( stdout ); return ( 0 ); }
Compile and run the above program to produce the following results. Here the program sends output to STDOUT just before it exits, otherwise it continues to buffer output. You can also use the fflush () function to flush (delete or move to the periphery) to see the result.
According to Tutorialspoint
Previous lesson: The rewind () function in C
Next lesson: Function setvbuf () in C
You should read it
Maybe you are interested
How to turn a photo into a painting using the Generative Fill function in Photoshop
How to use the TREND function in Excel
Google Sheets Functions to Simplify Your Budget Spreadsheets
Instructions for using the TRIMRANGE function to clean up Excel tables
How to master numerical data in Google Sheets with the AVERAGE function
Don't buy headphones if they lack this important function!