Like C, the C++ language has no built-in input and output facilities . Instead, input and output facilities for C++ are provided by the I/O Stream Library. For compatibility with C, C++ also supports the standard I/O functions of C. The I/O Stream Library supports a set of I/O operations, written in the C++ language, for the built-in types. You can extend these facilities to provide input and output functions for user-defined data types. For a complete description of the I/O Stream Library, see the Standard Class Library Guide.
There are four predefined I/O stream objects that you can use to perform standard I/O:
You can use these in conjunction with the overloaded <<
(insertion or output) and >> (extraction or input)
operators. To use these streams and operators, you must include
the header file iostream.h. The following example prints Hello
World! to standard output:
/** ** Hello World **/ #include <iostream.h> void main() { cout << "Hello World!" << endl; }
The manipulator endl acts as a newline character, causing any output following it to be directed to the next line. Because it also causes any buffered output to be flushed, endl is preferred over \n to end lines.
Overview of the C Language
Overview of the C++
Language
Cout
Cin
Cerr
Clog
Overloading Operators