The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017



Specifies the cin global stream.

extern istream cin;

The object controls extractions from the standard input as a byte stream. Once the object is constructed, the call cin.tie returns &cout.


In this example, cin sets the fail bit on the stream when it encounters non-numeric characters. The program clears the fail bit and strips the invalid character from the stream to proceed.

// iostream_cin.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

int main()
   int x;
   cout << "enter choice:";
   cin >> x;
   while (x < 1 || x > 4)
      cout << "Invalid choice, try again:";
      cin >> x;
      // not a numeric character, probably
      // clear the failure and pull off the non-numeric character
      if (
         char c;
         cin >> c;


Header: <iostream>

Namespace: std