Input and Output Functions
The stream classes std::istream
and std::ostream
are often used for the reading and writing of data. Use of std::istream
classes requires the <istream>
header; use of std::ostream
classes requires the <ostream>
header. You can have both with the header <iostream>
. std::istream
is a typedef for the class basic_istream
and the character type char
, std::ostream
for the class basic_ostream
respectively:
C++ has four predefined stream objects for the convenient dealing with the keyboard and the monitor.
Stream object | C pendant | Device | Buffered |
---|---|---|---|
std::cin |
stdin |
keyboard | yes |
std::cout |
stdout |
monitor | yes |
std::cerr |
stderr |
monitor | no |
std::clog |
&... |