<s>
In	O
the	O
C++	B-Language
programming	I-Language
language	I-Language
,	O
input/output	B-General_Concept
library	B-Library
refers	O
to	O
a	O
family	O
of	O
class	O
templates	B-Application
and	O
supporting	O
functions	O
in	O
the	O
C++	B-Language
Standard	I-Language
Library	I-Language
that	O
implement	O
stream-based	O
input/output	B-General_Concept
capabilities	O
.	O
</s>
<s>
It	O
is	O
an	O
object-oriented	B-Language
alternative	O
to	O
C	B-Language
's	O
FILE-based	O
streams	O
from	O
the	B-Language
C	I-Language
standard	I-Language
library	I-Language
.	O
</s>
<s>
Bjarne	O
Stroustrup	O
,	O
the	O
creator	O
of	O
C++	B-Language
,	O
wrote	O
the	O
first	O
version	O
of	O
the	O
stream	O
I/O	B-General_Concept
library	B-Library
in	O
1984	O
,	O
as	O
a	O
type-safe	O
and	O
extensible	O
alternative	O
to	O
C	B-Language
's	I-Language
I/O	I-Language
library	I-Language
.	O
</s>
<s>
The	O
library	B-Library
has	O
undergone	O
a	O
number	O
of	O
enhancements	O
since	O
this	O
early	O
version	O
,	O
including	O
the	O
introduction	O
of	O
manipulators	O
to	O
control	O
formatting	O
,	O
and	O
templatization	O
to	O
allow	O
its	O
use	O
with	O
character	O
types	O
other	O
than	O
char	O
.	O
</s>
<s>
Standardization	O
in	O
1998	O
saw	O
the	O
library	B-Library
moved	O
into	O
the	O
std	B-Language
namespace	I-Language
,	O
and	O
the	O
main	O
header	O
changed	O
from	O
<iostream.h> to <iostream>	O
.	O
</s>
<s>
Most	O
of	O
the	O
classes	O
in	O
the	O
library	B-Library
are	O
actually	O
very	O
generalized	O
class	O
templates	B-Application
.	O
</s>
<s>
Each	O
template	B-Application
can	O
operate	O
on	O
various	O
character	O
types	O
,	O
and	O
even	O
the	O
operations	O
themselves	O
,	O
such	O
as	O
how	O
two	O
characters	O
are	O
compared	O
for	O
equality	O
,	O
can	O
be	O
customized	O
.	O
</s>
<s>
However	O
,	O
the	O
majority	O
of	O
code	O
needs	O
to	O
do	O
input	B-General_Concept
and	I-General_Concept
output	I-General_Concept
operations	O
using	O
only	O
one	O
or	O
two	O
character	O
types	O
,	O
thus	O
most	O
of	O
the	O
time	O
the	O
functionality	O
is	O
accessed	O
through	O
several	O
typedefs	B-Language
,	O
which	O
specify	O
names	O
for	O
commonly	O
used	O
combinations	O
of	O
template	B-Application
and	O
character	O
type	O
.	O
</s>
<s>
For	O
example	O
,	O
basic_fstreamxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
refers	O
to	O
the	O
generic	O
class	B-Application
template	I-Application
that	O
implements	O
input/output	B-General_Concept
operations	O
on	O
file	B-Language
streams	O
.	O
</s>
<s>
It	O
is	O
usually	O
used	O
as	O
fstream	B-Language
which	O
is	O
an	O
alias	O
for	O
basic_fstreamxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
,	O
or	O
,	O
in	O
other	O
words	O
,	O
basic_fstream	O
working	O
on	O
characters	O
of	O
type	O
char	O
with	O
the	O
default	O
character	O
operation	O
set	O
.	O
</s>
<s>
The	O
classes	O
in	O
the	O
library	B-Library
could	O
be	O
divided	O
into	O
roughly	O
two	O
categories	O
:	O
abstractions	O
and	O
implementations	O
.	O
</s>
<s>
For	O
example	O
,	O
such	O
code	O
could	O
write	O
data	O
to	O
a	O
file	B-Language
,	O
a	O
memory	O
buffer	O
or	O
a	O
web	O
socket	O
without	O
a	O
recompilation	O
.	O
</s>
<s>
The	O
library	B-Library
provides	O
implementations	O
only	O
for	O
file-based	O
streams	O
and	O
memory	O
buffer-based	O
streams	O
.	O
</s>
<s>
The	O
classes	O
in	O
the	O
library	B-Library
could	O
also	O
be	O
divided	O
into	O
two	O
groups	O
by	O
whether	O
it	O
implements	O
low-level	O
or	O
high-level	O
operations	O
.	O
</s>
<s>
The	O
following	O
table	O
lists	O
and	O
categorizes	O
all	O
classes	O
provided	O
by	O
the	O
input-output	B-General_Concept
library	B-Library
.	O
</s>
<s>
Class	O
Explanation	O
Typedefs	B-Language
Stream	O
buffers	O
(	O
low	O
level	O
functionality	O
)	O
basic_streambuf	O
provides	O
abstract	O
low	O
level	O
input/output	B-General_Concept
interface	O
,	O
that	O
can	O
be	O
implemented	O
for	O
concrete	O
data	O
sources	O
or	O
sinks	O
.	O
</s>
<s>
wstreambuf	O
–	O
operates	O
on	O
characters	O
of	O
type	O
wchar_t	O
basic_filebuf	O
implements	O
low	O
level	O
input/output	B-General_Concept
interface	O
for	O
file-based	O
streams	O
.	O
</s>
<s>
wfilebuf	O
–	O
operates	O
on	O
characters	O
of	O
type	O
wchar_t	O
basic_stringbuf	O
implements	O
low	O
level	O
input/output	B-General_Concept
interface	O
for	O
string-based	O
streams	O
.	O
</s>
<s>
wistream	O
–	O
operates	O
on	O
characters	O
of	O
type	O
wchar_t	O
basic_ifstream	O
an	O
input	O
stream	O
that	O
wraps	O
a	O
file	B-Language
stream	O
buffer	O
.	O
</s>
<s>
wostream	O
–	O
operates	O
on	O
characters	O
of	O
type	O
wchar_t	O
basic_ofstream	O
an	O
output	O
stream	O
that	O
wraps	O
a	O
file	B-Language
stream	O
buffer	O
.	O
</s>
<s>
wiostream	O
–	O
operates	O
on	O
characters	O
of	O
type	O
wchar_t	O
basic_fstream	O
an	O
input/output	B-General_Concept
stream	O
that	O
wraps	O
a	O
file	B-Language
stream	O
buffer	O
.	O
</s>
<s>
wfstream	O
–	O
operates	O
on	O
characters	O
of	O
type	O
wchar_t	O
basic_stringstream	O
an	O
input/output	B-General_Concept
stream	O
that	O
wraps	O
a	O
string	O
stream	O
buffer	O
.	O
</s>
<s>
The	O
classes	O
of	O
the	O
input/output	B-General_Concept
library	B-Library
reside	O
in	O
several	O
headers	O
.	O
</s>
<s>
<ios>	O
contains	O
the	O
definitions	O
of	O
ios_base	O
and	O
basic_ios	O
classes	O
,	O
that	O
manage	O
formatting	O
information	O
and	O
the	O
associated	O
stream-buffer	O
.	O
</s>
<s>
<istream>	O
contains	O
the	O
definition	O
of	O
basic_istream	O
class	B-Application
template	I-Application
,	O
which	O
implements	O
formatted	O
input	O
.	O
</s>
<s>
<ostream>	O
contains	O
the	O
definition	O
of	O
basic_ostream	O
class	B-Application
template	I-Application
,	O
which	O
implements	O
formatted	O
output	O
.	O
</s>
<s>
<iostream> contains the definition of basic_iostream class template, which implements formatted input and output, and includes <ios>, <istream> and <ostream>	O
.	O
</s>
<s>
<fstream>	O
contains	O
the	O
definitions	O
of	O
basic_ifstream	O
,	O
basic_ofstream	O
and	O
basic_fstream	O
class	O
templates	B-Application
which	O
implement	O
formatted	O
input	O
,	O
output	O
and	O
input/output	B-General_Concept
on	O
file	B-Language
streams	O
.	O
</s>
<s>
<sstream>	O
contains	O
the	O
definitions	O
of	O
basic_istringstream	O
,	O
basic_ostringstream	O
and	O
basic_stringstream	O
class	O
templates	B-Application
which	O
implement	O
formatted	O
input	O
,	O
output	O
and	O
input/output	B-General_Concept
on	O
string-based	O
streams	O
.	O
</s>
<s>
<iomanip>	O
contains	O
formatting	O
manipulators	O
.	O
</s>
<s>
<iosfwd>	O
contains	O
forward	O
declarations	O
of	O
all	O
classes	O
in	O
the	O
input/output	B-General_Concept
library	B-Library
.	O
</s>
<s>
There	O
are	O
twelve	O
stream	O
buffer	O
classes	O
defined	O
in	O
the	O
C++	B-Language
language	I-Language
as	O
the	O
table	O
.	O
</s>
<s>
basic_ios	O
is	O
commonly	O
known	O
as	O
simply	O
ios	B-Language
or	O
wios	O
,	O
which	O
are	O
two	O
typedefs	B-Language
for	O
basic_ios	O
with	O
a	O
specific	O
character	O
type	O
.	O
</s>
<s>
Name	O
descriptionios	O
convenience	O
typedef	B-Language
for	O
a	O
basic_ios	O
working	O
with	O
characters	O
of	O
type	O
charwios	O
convenience	O
typedef	B-Language
for	O
a	O
basic_ios	O
working	O
with	O
characters	O
of	O
type	O
wchar_tstreamoff	O
supports	O
internal	O
operations.streampos	O
holds	O
the	O
current	O
position	O
of	O
the	O
buffer	O
pointer	O
or	O
file	O
pointer.wstreampos	O
holds	O
the	O
current	O
position	O
of	O
the	O
buffer	O
pointer	O
or	O
file	O
pointer.streamsize	O
specifies	O
the	O
size	O
of	O
the	O
stream	O
.	O
</s>
<s>
C++	B-Language
input/output	B-General_Concept
streams	O
are	O
primarily	O
defined	O
by	O
iostream	O
,	O
a	O
header	B-Language
file	I-Language
that	O
is	O
part	O
of	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
(	O
the	O
name	O
stands	O
for	O
Input/Output	B-General_Concept
Stream	O
)	O
.	O
</s>
<s>
In	O
C++	B-Language
and	O
its	O
predecessor	O
,	O
the	O
C	B-Language
programming	I-Language
language	I-Language
,	O
there	O
is	O
no	O
special	O
syntax	O
for	O
streaming	O
data	O
input	O
or	O
output	O
.	O
</s>
<s>
Instead	O
,	O
these	O
are	O
combined	O
as	O
a	O
library	B-Library
of	O
functions	O
.	O
</s>
<s>
Like	O
the	O
cstdio	B-Language
header	O
inherited	O
from	O
C	B-Language
's	O
stdio.h	B-Language
,	O
iostream	O
provides	O
basic	O
input	B-General_Concept
and	I-General_Concept
output	I-General_Concept
services	O
for	O
C++	B-Language
programs	I-Language
.	O
</s>
<s>
iostream	O
uses	O
the	O
objects	O
cin	O
,	O
cout	B-Language
,	O
cerr	B-Language
,	O
and	O
clog	O
for	O
sending	O
data	O
to	O
and	O
from	O
the	O
standard	B-Operating_System
streams	I-Operating_System
input	O
,	O
output	O
,	O
error	O
(	O
unbuffered	O
)	O
,	O
and	O
log	O
(	O
buffered	O
)	O
respectively	O
.	O
</s>
<s>
As	O
part	O
of	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
,	O
these	O
objects	O
are	O
a	O
part	O
of	O
the	O
std	B-Language
namespace	I-Language
.	O
</s>
<s>
The	O
cout	B-Language
object	O
is	O
of	O
type	O
ostream	B-Language
,	O
which	O
overloads	O
the	O
left	O
bit-shift	O
operator	O
to	O
make	O
it	O
perform	O
an	O
operation	O
completely	O
unrelated	O
to	O
bitwise	O
operations	O
,	O
and	O
notably	O
evaluate	O
to	O
the	O
value	O
of	O
the	O
left	O
argument	O
,	O
allowing	O
multiple	O
operations	O
on	O
the	O
same	O
ostream	B-Language
object	O
,	O
essentially	O
as	O
a	O
different	O
syntax	O
for	O
method	O
cascading	O
,	O
exposing	O
a	O
fluent	O
interface	O
.	O
</s>
<s>
The	O
cerr	B-Language
and	O
clog	O
objects	O
are	O
also	O
of	O
type	O
ostream	B-Language
,	O
so	O
they	O
overload	O
that	O
operator	O
as	O
well	O
.	O
</s>
<s>
Other	O
manipulators	O
can	O
be	O
found	O
using	O
the	O
header	O
iomanip	B-Language
.	O
</s>
<s>
Some	O
implementations	O
of	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
have	O
significant	O
amounts	O
of	O
dead	B-Application
code	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
GNU	O
libstdc++	B-Language
automatically	O
constructs	O
a	O
locale	B-Device
when	O
building	O
an	O
ostream	B-Language
even	O
if	O
a	O
program	O
never	O
uses	O
any	O
types	O
(	O
date	O
,	O
time	O
or	O
money	O
)	O
that	O
a	O
locale	B-Device
affects	O
,	O
</s>
<s>
program	O
that	O
uses	O
<iostream> of GNU libstdc++ produces an executable an order of magnitude larger than an equivalent program that uses <cstdio>	O
.	O
</s>
<s>
There	O
exist	O
partial	O
implementations	O
of	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
designed	O
for	O
space-constrained	O
environments	O
;	O
their	O
<iostream>	O
may	O
leave	O
out	O
features	O
that	O
programs	O
in	O
such	O
environments	O
may	O
not	O
need	O
,	O
such	O
as	O
locale	B-Device
support	O
.	O
</s>
<s>
The	O
following	O
example	O
creates	O
a	O
file	B-Language
called	O
'	O
file.txt	O
'	O
and	O
puts	O
the	O
text	O
'	O
Hello	O
,	O
world!	O
 '	O
</s>
