Rogue Wave banner
Previous fileTop of DocumentContentsNext file

7.1 The Predefined Streams

There are eight predefined standard streams that are automatically created and initialized at program start. These standard streams are associated with the C standard files stdin, stdout, and stderr, as shown in Table 1:

Table 4 -- Predefined standard streams with their associated C standard files

Narrow character streamWide character streamAssociated C standard files
cin
wcin
stdin
cout
wcout
stdout
cerr
wcerr
stderr
clog
wclog
stderr

Like the C standard files, these streams are all associated by default with the terminal.

The difference between clog and cerr is that clog is fully buffered, whereas output to cerr is written to the external device after each formatting. With a fully buffered stream, output to the actual external device is written only when the buffer is full. Thus clog is more efficient for redirecting output to a file, while cerr is mainly useful for terminal I/O. Writing to the external device after every formatting, to the terminal in the case of cerr, serves the purpose of synchronizing output to and input from the terminal.

The standard streams are initialized in such a way that they can be used in constructors and destructors of static objects.

Also, the predefined streams are synchronized with their associated C standard files. See Section 14.6 for details.


Previous fileTop of DocumentContentsNext file

©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.


OEM Release, June 1998