In C, what’s the size of stdout buffer?

The actual size is defined by the individual implementation; the standard doesn’t mandate a minimum size (based on what I’ve been able to find, anyway). Don’t have a clue on how you’d determine the size of the buffer.

Edit

Chapter and verse:

7.19.3 Files


3 When a stream is unbuffered, characters are intended to appear from the source or at the
destination as soon as possible. Otherwise characters may be accumulated and
transmitted to or from the host environment as a block. When a stream is fully buffered,
characters are intended to be transmitted to or from the host environment as a block when
a buffer is filled. When a stream is line buffered, characters are intended to be
transmitted to or from the host environment as a block when a new-line character is
encountered. Furthermore, characters are intended to be transmitted as a block to the host
environment when a buffer is filled, when input is requested on an unbuffered stream, or
when input is requested on a line buffered stream that requires the transmission of
characters from the host environment. Support for these characteristics is
implementation-defined, and may be affected via the setbuf and setvbuf functions
.

Emphasis added.

“Implementation-defined” is not a euphemism for “I don’t know”, it’s simply a statement that the language standard explicitly leaves it up to the implementation to define the behavior.

And having said that, there is a non-programmatic way to find out; consult the documentation for your compiler. “Implementation-defined” also means that the implementation must document the behavior:

3.4.1

1 implementation-defined behavior
unspecified behavior where each implementation documents how the choice is made

2 EXAMPLE An example of implementation-defined behavior is the propagation of the high-order bit
when a signed integer is shifted right.

Leave a Comment