title: C++ How to only accept a char input and make the program exit if user inputs string or int etc
body: <p>Hey guys so I'm writing a program where I can only in one letter(ex. a,b,c) and I want the program to exit if the user tries to enter anything else ex)string int etc. The code sample I have so far is this. When I try to run this it the program will always say that the input is a letter.</p>
  
  <pre><code>    #include &lt;iostream&gt;
      using namespace std;
      int main(){
  
      char guess;
      bool isnotletter
      cout&lt;&lt;"Enter your guess"&lt;&lt;endl;
      cin&gt;&gt;guess;
  
      isnotletter=cin.fail();//cin.fail returns true if the input is something that disagrees with the data type (ex string and int would)
  
  
      cin.clear();
      cin.ignore(numeric_limits&lt;streamsize&gt;::max(),'\n');
  
      if(isnotletter==true)
      {
          cout&lt;&lt;"Error"&lt;&lt;endl;
          exit(1);
      }
  
      else
         cout&lt;&lt;"You are a letter"&lt;&lt;endl;
  }
  </code></pre>