# <iostream>
<iostream>
# ``
* * *
Include the [iostreams](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_cpp.html#iostreams)
standard header **``**
to declare objects that control reading from and writing to the
[standard streams](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20streams).
This is often the *only* header you
need include to perform input and output from a C++ program.
The objects fall into two groups:
- `cin`,
`cout`,
`cerr`, and
`clog` are
[byte oriented](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#byte%20oriented),
performing conventional byte-at-a-time transfers
- `wcin`,
`wcout`,
`wcerr`, and
`wclog` are
[wide oriented](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#wide%20oriented),
translating to and from the
[wide characters](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_charset.html#Wide-Character%20Encoding)
that the program manipulates internally
Once you perform
[certain operations](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#Stream%20States)
on a stream, such as the
[standard input](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20input),
you cannot perform operations of a different orientation on
the same stream. Hence, a program cannot operate interchangeably on both
`cin` and
`wcin`, for example.
All the objects declared in this header share a peculiar
property -- you can assume they are
**constructed** before any
static objects you define, in a translation unit that includes
``. Equally, you can assume that
these objects are **not destroyed** before the destructors for any
such static objects you define. (The output streams are, however,
flushed during program termination.)
Hence, you can safely read from
or write to the standard streams prior to program startup and
after program termination.
This guarantee is *not* universal, however. A static
constructor may call a function in another translation unit.
The called function cannot assume that the objects declared in
this header have been constructed, given the uncertain order
in which translation units participate in static construction.
To use these objects in such a context, you must first construct
an object of class
**`ios_base::Init`**,
as in:
#include
void marker()
{ // called by some constructor
ios_base::Init unused_name;
cout << "called fun" << endl;
}Copy to clipboard
namespace std {
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
} // namespace stdCopy to clipboard
## `cerr`
extern ostream cerr;Copy to clipboard
The object controls unbuffered insertions to the
[standard error](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20error) output
as a [byte stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#byte%20stream).
Once the object is constructed, the expression
`cerr.flags() &
unitbuf` is nonzero.
## `cin`
extern istream cin;Copy to clipboard
The object controls extractions from the
[standard input](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20input)
as a [byte stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#byte%20stream).
Once the object is constructed, the call
`cin.tie()` returns
`&cout`.
## `clog`
extern ostream clog;Copy to clipboard
The object controls buffered insertions to the
[standard error](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20error) output
as a [byte stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#byte%20stream).
## `cout`
extern ostream cout;Copy to clipboard
The object controls insertions to the
[standard output](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20output)
as a [byte stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#byte%20stream).
## `wcerr`
extern wostream wcerr;Copy to clipboard
The object controls unbuffered insertions to the
[standard error](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20error) output
as a [wide stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#wide%20stream).
Once the object is constructed, the expression
`wcerr.flags() &
unitbuf` is nonzero.
## `wcin`
extern wistream wcin;Copy to clipboard
The object controls extractions from the
[standard input](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20input)
as a [wide stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#wide%20stream).
Once the object is constructed, the call
`wcin.tie()` returns
`&wcout`.
## `wclog`
extern wostream wclog;Copy to clipboard
The object controls buffered insertions to the
[standard error](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20error) output
as a [wide stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#wide%20stream).
## `wcout`
extern wostream wcout;Copy to clipboard
The object controls insertions to the
[standard output](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#standard%20output)
as a [wide stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_file.html#wide%20stream).
* * *
See also the
**[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the
**[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**.
*[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger. All rights reserved.*
Last Published: Oct 06, 2026
Previous Topic
Next Topic