The <iostream>
header declares the eight standard stream objects: cerr
, cin
, clog
, cout
, wcerr
, wcin
, wclog
, and wcout
. These objects are initialized when the first instance of io
s
_base::
I
nit
is constructed (or ealier), or before the main
program starts.
Error message stream
extern ostream cerr
The cerr
object is a standard output stream associated with the C stderr
file. It is typically used for error messages. When the cerr
object is initialized, it sets the unitbuf
flag, which flushes the output buffer after every operation.
clog variable, wcerr variable, ostream in <ostream>
Normal input stream
extern istream cin
The cin
object is a standard input stream associated with the C stdin
file. It is used for normal program input.
wcin variable, istream in <istream>
Log output stream
extern ostream clog
The clog
object is a standard output stream associated with the C stderr
file. Unlike cerr
, the clog
object does not set the unitbuf
flag. This makes it more suitable for writing less critical messages that are not considered normal program output, such as debugging or logging messages.
cerr variable, wclog variable, ostream in <ostream>
Normal output stream
extern ostream cout
The cout
object is a standard input stream associated with the C stdout
file. It is used for normal program output.
wcout variable, ostream in <ostream>
Wide error message stream
extern wostream wcerr
The wcerr
object is a standard output stream associated with the C stderr
file. It is typically used for error messages. When the wcerr
object is initialized, it sets the unitbuf
flag, which flushes the output buffer after every operation.
cerr variable, wclog variable, wostream in <ostream>
Wide input stream
extern wistreamw cin
The wcin
object is a standard input stream associated with the C stdin
file. It is used for wide program input.
cin variable, wistream in <istream>
Wide log output stream
extern wostreamw clog
The wclog
object is a standard output stream associated with the C stderr
file. Unlike wcerr
, the wclog
object does not set the unitbuf
flag. This makes it more suitable for writing less critical messages that are not considered normal program output, such as debugging or logging messages.
clog variable, wcerr variable, wostream in <ostream>
Wide output stream
extern wostream wcout
The wcout
object is a standard input stream associated with the C stdout
file. It is used for wide program output.
cout variable, wostream in <ostream>