#### 12.20.1 Buffering Concepts

There are three different kinds of buffering strategies:

- Characters written to or read from an unbuffered stream are transmitted individually to or from the file as soon as possible.
- Characters written to a line buffered stream are transmitted to the file in blocks when a newline character is encountered.
- Characters written to or read from a fully buffered stream are transmitted to or from the file in blocks of arbitrary size.

Newly opened streams are normally fully buffered, with one exception: a stream connected to an interactive device such as a terminal is initially line buffered. See Controlling Buffering, for information on how to select a different kind of buffering. Usually the automatic selection gives you the most convenient kind of buffering for the file or device you open.

The use of line buffering for interactive devices implies that output messages ending in a newline will appear immediately—which is usually what you want. Output that doesn't end in a newline might or might not show up immediately, so if you want them to appear immediately, you should flush buffered output explicitly with `fflush`, as described in Flushing Buffers.