title: How to check user input?
body: <p>SO I want to be able to invalidate all user input except a certain word, like <code>'K'</code> or <code>'C'</code>. I'm not sure at all how to do this. So if they mispell it to "celcius" or "husdhfjae", my program would say <code>"Input invalid, please enter K or C."</code></p>
  
  <p>Please nothing too complicated, because I just started. Thank you :) </p>
  
  <pre><code>//  CS 575,HW #1B, Ravela Smyth
  
  //  This program converts from Fahrenheit to Celsius or Kelvin
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main() {
      string input;
      double Fahrenheit, celsius, kelvin;
      cout &lt;&lt; "Hi! What is the weather today in Fahrenheit?? " &lt;&lt; endl;
      cin &gt;&gt; Fahrenheit;
      cout &lt;&lt; "Would you like to convert this temperature to Celsius or Kelvin? (C/K)" &lt;&lt; endl;
      cin &gt;&gt; input;
      if (input == "C")
      {
            celsius = (5 * (Fahrenheit - 32)) / 9;
            cout &lt;&lt; "Today's weather in Celsius is " &lt;&lt; celsius &lt;&lt; " degrees! " &lt;&lt; endl;
      }
      else if (input == "c")
      {
            celsius = (5 * (Fahrenheit - 32)) / 9;
            cout &lt;&lt; "Today's weather in Celsius is " &lt;&lt; celsius &lt;&lt; " degrees! " &lt;&lt; endl;
      }
      else if (input == "K")
      {
            kelvin = (5 * (Fahrenheit + 459.67)) / 9;
            cout &lt;&lt; "Today's weather in Kelvin is " &lt;&lt; kelvin &lt;&lt; " degrees!" &lt;&lt; endl;
      }
      else if (input == "k")
      {
            kelvin = (5 * (Fahrenheit + 459.67)) / 9;
            cout &lt;&lt; "Today's weather in Kelvin is " &lt;&lt; kelvin &lt;&lt; " degrees!" &lt;&lt; endl;
      }
  
  return 0;
  }
  </code></pre>