title: Check if input is integer
body: <p>In order to learn C++, I'm translating a program I wrote in Python.</p>
  
  <p>I wrote this</p>
  
  <pre><code>n = 0
  while n &lt; 2:
      try:
          n = int(raw_input('Please insert an integer bigger than 1: '))
      except ValueError:
          print 'ERROR!'
  </code></pre>
  
  <p>in order to get an integer bigger than 1 from the user.</p>
  
  <p>This is what I wrote in C++ for the moment:</p>
  
  <pre><code>int n = 0;
  while (n &lt; 2) {
      cout &lt;&lt; "Please insert an integer bigger than 1: ";
      cin &gt;&gt; n;
  }
  </code></pre>
  
  <p>I took a look at try-catch and it seems pretty straight forward. My concern is about how to check the input is an integer. I read about cin.fail() but I couldn't find any official document and I didn't really get how it works.</p>
  
  <p>So, how can I check if the input is integer?</p>
  
  <p>More in general, how can I check if the input is "<em>anything</em>"?</p>