Say i open a file using fopen() for writing and leave it open..
i keep writing to it, finally the buffer will reach its limit save the data to file(just like fflush)
right?
i want to know when will this happen, what is the limit of buffer? can i change it to my desired size like 10kb or 1mb?
Please help, i googled but no luck
Thanks
The default C I/O buffer size is usually the same as the preprocessor macro BUFSIZ (defined in stdio.h), although there is no requirement that it is exactly that.
In my tests, Linux and IBM use exactly BUFSIZ, but Sun doesn't. It is an implementation detail of the C library, and the only way to find out for sure is to examine the library source code, or trace the system calls made by a test program.
You can change the buffer or the condition when the flush happens by calling setbuf() or setvbuf().
Okay i tried using setbuf(), set the buffer size to 10 bytes but it does not save data after every 10 bytes..
i did this
opened the file for writing
wrote around 15 characters (equal 15 bytes) to it
did not close the file/did not terminate the program
data was not saved
data was not saved even after i terminated the program
please provide a code, if you have it working
Thanks :)