title: C++ Input errors when entering a floating point instead of integer
body: <p>I'm trying to write something for class that is basically a tiny online store. The idea is to display some amount of stock, ask the user how many he/she wants, and display the cart when they are finished. I have everything I need and it runs perfectly unless the user says they want a floating point amount of something.<br>
  We are supposed to check all inputs for errors and continue to ask the user until a correct input is entered. What I have accounts for any entry (that I know of) consisting of letters and numbers, but when a decimal is entered, it rounds down to the nearest integer, uses that for the current item, then skips to the next input chance (the next item) and immediately gives an error message there.</p>
  
  <pre><code>void printError(int stock, int &amp;numberOfCopies){
          cin.clear();
          cin.ignore(INT_MAX, '\n');
          cout &lt;&lt; "Invalid amount" &lt;&lt; endl &lt;&lt; "Enter a number from 0 - " &lt;&lt; stock &gt;&lt;&lt; ": ";
          cin &gt;&gt; numberOfCopies;
  }
  
  int getQuantity(string title, int stock){
      int numberOfCopies;
      cin &gt;&gt; numberOfCopies;
      while (cin.fail() || numberOfCopies &lt; 0 || numberOfCopies &gt; stock){
          printError(stock, numberOfCopies);
      }
          if (numberOfCopies == 1){
              cout &lt;&lt; endl &lt;&lt; numberOfCopies &lt;&lt; " copy of " &lt;&lt; title &lt;&lt; " has been &gt;added to your cart" &lt;&lt; endl;
          }
          else if (numberOfCopies &gt; 1 &amp;&amp; numberOfCopies &lt;= stock){
              cout &lt;&lt; endl &lt;&lt; numberOfCopies &lt;&lt; " copies of " &lt;&lt; title &lt;&lt; " have &gt;been added to your cart" &lt;&lt; endl;
          }
          else if (numberOfCopies == 0){
              cout &lt;&lt; "You did not change your cart" &lt;&lt; endl;
          }
      return numberOfCopies;
  }
  int numberOfCopies1 = getQuantity(title1, stock1);
  </code></pre>
  
  <p>This is what I have to check for errors right now (title1 and stock1 are predefined). I'm using <code>cin.fail()</code> to check for values that aren't integers, but it doesn't work when entering decimals.<br>
  What am I overlooking here? </p>