5.9.3.3. Iostream: Reading from the Standard Input (optional)

cin >> x;

Read a value from the standard input and store it into variable x. The type of thing read depends on the type of x. For example, if x has type int, then cin reads an integer.

If x has type char, then the normal behavior is to skip over white-space characters and then get the first non-white-space character.


cin.get()

This expression reads one character from the standard input and yields its integer code. For example,
  int c;
  c = cin.get();
reads a character and stores its code into c. It does not skip over white space characters. If there are no more characters in the standard input then cin.get() yields EOF, which is −1.

cout.eof()

This is true if an attempt has been made to read something, but the attempt failed because there was nothing left in the file.

cout.fail()

This is true if the most recent attempt to read something failed. Be sure to use this. For example, you would typically do
  c >> x;
  if(cin.fail())
  {
    (what to do if x could not be read)
  }