cin

The cin class object is associated with standard input. You can use the input operator in conjunction with cin to read a value from standard input. By default, white space (including blanks, tabs, and new lines) is disregarded by the input operator. For example:

/**
 ** This example illustrates the cin operator
 **/

#include <iostream.h>
main()
{
      double val1, val2;
      cout << "Enter two numeric values:" << endl;
      cin >> val1 >> val2;
      cout   << "The first value entered is " << val1
             << " and the second value is "
             << val2 << "." << endl;
}

If the values 1.2 and 3.4 are entered through standard input, the above program prints the following to standard output:

Enter two numeric values:
1.2
3.4
The first value entered is 1.2 and the second value is 3.4.

Any white space entered between the two numeric values is disregarded by the input operator.

The input operator is defined to accept arguments of any of the fundamental data types, as well as pointers, references and array types. You can also overload the input operator to define input for your own class types.