The IO Operators

The I/O Operators

In C++, the << and the >> are overloaded to perform I/O operations. When used in an expression in which the left operand is a stream, the >> is an input operator and the << is an output operator. In the language of C++, the >> is called an extractor because it extracts data from the input stream. The << is called an inserter because it inserts data into the output stream. The general forms of these operators are shown here:

 input-stream >> variable; output-stream << expression 

For example, the following fragment inputs two integer variables:

int i, j; cin >> i >> j;

The following statement displays “This is a test 10 20”:

cout << "This is a test " << 10 << << ' ' << 4*5;

The I/O operators are not supported by C.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net