Buffers
stdio implements buffered input and output. What's a buffer ?
- A buffer is a portion of memory set aside to store data, often before it
is sent to an external device or as it is received from an external device
- Buffers are common to many kinds of systems including mechanical ones.
- Film projectors tend to pull the film at a variable rate, so a loop of
extra film is made between the feed and takeup reels.
- A water tank on the top of an apartment building acts as a buffer for
water use in the building
Streams can be :
- Fully buffered: data is moved only when the buffer is full
- Line buffered: the buffer is a line (e.g., sequence of chars terminated
with a new line
- Unbuffered: no buffering
The C streams we are studying are line buffered.
For buffered output, the information is queued up in the buffer until it
is full and then written.
Last Modified -