Relying on
BUFSIZ
suggests that the buffer size will always be a constant. Is this always the case?
No, it's not.
In the call to setvbuf
int setvbuf(FILE * restrict stream, char * restrict buf, int mode, size_t size);
You can choose the value for size
yourself. (Although you may choose to use BUFSIZE
) The macro BUFSIZE
only works when you call setbuf
void setbuf(FILE * restrict stream, char * restrict buf);
It is equivalent to the setvbuf
function invoked with the values _IOFBF
for mode and BUFSIZ
for size, or (if buf
is a null pointer), with the value _IONBF
for mode.