Buffered I/O subsystem
My project requires me to have a function that intializes the system so that it is setup and ready to go with the correct number of buffers being applied. The problem comes from the fact that it requires me to set the stdout and stderr buffers to be set a certain size my problem is that I don't know if I am supposed to just create an unsigned integer value that represents the buffer size or whether I have to some method that is specific to the I/O streams I was curious if anyone knows whether or not there are specific I/O methods that deal with setting buffers for the stdout and stderr streams.
The mode options are:
static char stdout_buf[N];
static char stderr_buf[N];
int main ( void )
/* Before doing anything else with stdout and stderr */
setvbuf ( stdout, stdout_buf, _IOFBF, N );
setvbuf ( seterr, stderr_buf, _IOFBF, N );
_IOFBF - Full buffering
_IOLBF - Line buffering
_IONBF - unbuffered
I think you can figure out the others, if not, check you reference manual. setvbuf is in stdio.h.
Well you can use the setvbuf() call to change the buffering of a stream.
But I'd leave stderr alone. It's unbuffered by default, so that error messages are not lost in a buffer if the program crashes between reporting the error and finally printing the error.