The operating system associates a file handle with each of the streams as follows:
| File Handle | C Stream | C++ Stream |
|---|---|---|
| 0 | stdin | cin and wcin |
| 1 | stdout | cout and wcout |
| 2 | stderr | cerr, clog, wcerr, and wclog |
The file handle and stream are not equivalent. There may be situations where a file handle is associated with a different stream. For example, file handle 2 may be associated with a stream other than stderr, cerr, or clog.
![]()
Stream
Processing
Standard
Streams
![]()
C Library
Functions: Stream Input/Output
Considerations for
Programming Stream I/O