What is the size of the buffer associated with the file when the file is opened with the fopen () library function?

When FILE is opened with fopen (), a buffer is associated with it for writing and reading from files, which is executed to avoid direct disk access, because it is expensive.

I found in some online tutorials saying when we load a file into main memory (RAM) four things get created stdin, stdout, stderror, Buffer and this buffer is used to read / write to the file, I am curious to know how much size is allocated OS for this buffer, does it depend on OS architecture? Is it possible to find out its size?

+3


source to share


1 answer


The default buffer size is a macro constant BUFSIZ

defined in stdio.h

. The meaning is implementation dependent. You can use setvbuf()

to change buffering mode (Full / Line / No buffering) and buffer size.

Link:



+5


source







All Articles