|
Stream I/O |
Top Previous Next |
|
The model of I/O supported by the standard I/O package is known as stream I/O.
In the stream I/O model, a file is considered as a sequence of char values. A notional file pointer, maintained by the I/O functions, indicates the character position within the file at which the next character will be read or written. The file pointer is advanced automatically as characters are read or written. Allowing you to position the file pointer explicitly supports random file access.
The basic operations provided by the standard I/O package in support of the stream I/O model are therefore the following:
Other, higher level, operations (e.g., write a string) are built up directly from these primitive operations. Because of this, calls on the character level functions and the higher-level functions may be freely intermixed and characters are still transferred in the expected order.
Devices such as the keyboard and the screen are included in the stream I/O model: characters may be read or written from them as appropriate (in principle, one at a time), but positioning operations are not supported.
|