title: check std::cin variable type
body: <p>i am learning about functions and function arguments. i am attempting to right a function called <code>int repeat(int rep){...}</code> below is the code for the function <code>int repeat()</code>.</p>
  
  <pre><code>int repeat(int rep){
      std::cout &lt;&lt; "Do you wish to factorial another number? Y or N: " &lt;&lt;
          std::endl;
      char c1;
      restart:
      std::cin &gt;&gt; c1; /* pretend user input is "7". the below if statement should execute the `throw`            statement. However it does not evaluate the if statement as true. and passes over it.*/
      try{
          if (std::cin.fail()){
              throw std::runtime_error(" Must enter y for yes or n for no.");
          }
          if (c1 == 'y' || c1 == 'Y'){
              return rep = 1;
          }
          else{
              //system("pause");
              return rep = 0;
          }
      }
      catch (std::runtime_error err2){
          std::cout &lt;&lt; err2.what() &lt;&lt; std::endl;
          std::cin.clear();
          std::cin.ignore();
          goto restart;
      }
  }
  </code></pre>
  
  <p>the issue in my code appears with the first if statement: <code>
  if (std::cin.fail()){   throw std::runtime_error(" Must enter y for yes or n for no.");
  }</code></p>
  
  <p>i am attempting to use <code>std::cin.fail()</code> to test rather the input that is stored in the variable <code>char c1</code> is in fact a char type. Example: if the user inputs a number into <code>c1</code> then the if statement should execute the <code>throw</code> statement. however it does not happen. Can anyone assist in making the if statement execute correctly if a user inputs a non char type into the <code>std::cin &gt;&gt; c1</code>?</p>
  
  <p>Note: i have used this method in a different part of the program to test if an input into<code>std::cin</code> is of type int and the if statement works as intended.</p>