title: to check type of input in c++
body: <p>## To check type of data entered in cpp ##</p>
  
  <pre><code>int main()
  {
      int num;
      stack&lt;int&gt; numberStack;
      while(1)
      {
          cin&gt;&gt;num;
          if(isdigit(num))
              numberStack.push(num);
          else
              break;
      }
  return(0);
  }
  </code></pre>
  
  <p>If I declare a variable as interger, and I input an alphabet, say 'B', instead of the number, can I check this behavior of user? My code above exits when first number is entered and does not wait for more inputs.</p>