Home

iostreams

Iostreams refers to the C++ standard library facilities that implement input and output using stream objects. It provides a hierarchy of stream classes and associated buffers that decouple I/O operations from the underlying devices, enabling formatted and unformatted I/O through a uniform interface.

Core classes include basic_istream, basic_ostream, and basic_iostream, templates parameterized by character type and traits. Common specializations

Internally, iostreams rely on stream buffers (std::streambuf) and formatting state embedded in i/o manipulators such as

Design and usage emphasize type safety and extensibility, with locale support and facets that influence formatting

include
istream,
ostream,
iostream
and
their
wide-character
counterparts.
The
standard
objects
std::cin,
std::cout,
std::cerr,
and
std::clog
are
instances
of
these
classes
and
serve
as
primary
entry
points
for
input
and
output.
I/O
is
typically
performed
with
the
insertion
operator
(<<)
and
the
extraction
operator
(>>)
which
dispatch
to
the
appropriate
virtual
functions
to
format
data
or
parse
input.
std::endl,
std::setw,
std::setfill,
and
std::setprecision.
The
library
tracks
state
flags
(eofbit,
failbit,
badbit,
good)
and
can
throw
exceptions
if
enabled
via
std::ios_base::exceptions.
The
ecosystem
also
includes
string
streams
(std::stringstream)
for
in-memory
I/O
and
file
streams
(std::ifstream,
std::ofstream,
std::fstream)
which
extend
the
same
interface
to
files.
and
parsing.
Iostreams
form
a
cohesive
alternative
to
printf-style
I/O
in
C++
and
are
a
fundamental
part
of
the
standard
library,
widely
used
for
console
I/O,
logging,
and
data
serialization
in
portable
C++
programs.