title: how do I check if input from cin is a double?
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/514420/how-to-validate-numeric-input-c">How to validate numeric input C++</a><br>
    <a href="https://stackoverflow.com/questions/3273993/how-do-i-validate-user-input-as-a-double-in-c">how do I validate user input as a double in C++?</a>  </p>
  </blockquote>
  
  
  
  <p>I need to get input from the command line and check if it is a valid number... storing it as a double. If the input is invalid, I need to keep asking for a number.</p>
  
  <pre><code>double x;
  cout &lt;&lt; '&gt;';
  cin &gt;&gt; x;
  
  
  while (/*x is invalid*/){
   cout &lt;&lt; "Invalid Input! Please input a number." &lt;&lt; endl;
   cout &lt;&lt; '&gt;';
   cin &gt;&gt; x;
  }
  </code></pre>
  
  <p>So how do I check if it is valid? </p>