C++ I/O [C++ Reference]
Keywords: io,start
Date: 2010-04-18T22:30:09-0700

[[C++ I/O]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

# C++ I/O

The <iostream> library automatically defines a few standard objects:

- cout, an object of the ostream class, which displays data to the standard output device.
- cerr, another object of the ostream class that writes unbuffered output to the standard error device.
- clog, like cerr, but uses buffered output.
- cin, an object of the istream class that reads data from the standard input device.

The <fstream> library allows programmers to do file input and output with the ifstream and ofstream classes. C++ programmers can also do input and output from strings by using the stringstream class.

Some of the behavior of the C++ I/O streams (precision, justification, etc) may be modified by manipulating various I/O stream format flags.

I/O Constructors | constructors
bad | true if an error occurred
clear | clear and set status flags
close | close a stream
eof | true if at the end-of-file
exceptions | set the stream to throw exceptions on errors
fail | true if an error occurred
fill | manipulate the default fill character
flags | access or manipulate io_stream_format_flags
flush | empty the buffer
gcount | number of characters read during last input
get | read characters
getline | read a line of characters
good | true if no errors have occurred
ignore | read and discard characters
is_open | check if a file is open
open | open a new stream
peek | check the next input character
precision | manipulate the precision of a stream
put | write characters
putback | return characters to a stream
rdstate | returns the state flags of the stream
read | read data into a buffer
seekg | perform random access on an input stream
seekp | perform random access on output streams
setf | set format flags
sync_with_stdio | synchronize with standard I/O
tellg | read input stream pointers
tellp | read output stream pointers
unsetf | clear io_stream_format_flags
width | access and manipulate the minimum field width
write | write characters

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •