std::setbuf (3) - Linux Man Pages
Defined in header <cstdio>
void setbuf( std::FILE* stream, char* buffer );
Sets the internal buffer to use for I/O operations performed on the C stream stream.
If buffer is not null, equivalent to std::setvbuf(stream, buffer, _IOFBF, BUFSIZ)
If buffer is null, equivalent to std::setvbuf(stream, NULL, _IONBF, 0), which turns off buffering.
stream - the file stream to set the buffer to.
buffer - pointer to a buffer for the stream to use. If NULL is supplied, the buffering is turned off. If not null, must be able to hold at least BUFSIZ characters
If BUFSIZ is not the appropriate buffer size, std::setvbuf can be used to change it.
std::setvbuf should also be used to detect errors, since std::setbuf does not indicate success or failure.
This function may only be used after stream has been associated with an open file, but before any other operation (other than a failed call to std::setbuf/std::setvbuf).
A common error is setting the buffer of stdin or stdout to an array whose lifetime ends before the program terminates:
setbuf may be used to disable buffering on streams that require immediate output
// Run this code