title: Cin Not Working in While Loop
body: <p>A simple code below; I'm trying to use <code>cin</code> in the <code>while</code> loop to capture the correct user input (<em>integer instead of string</em>), and it seems as if the while loop is ignoring it.</p>
  
  <pre><code>int main(){
       string Host = "Host: ";
       string Intro = "Type in a number. ";
  
       cout &lt;&lt; Host &lt;&lt; Intro;
  
       int PlayerID;
       cin &gt;&gt; PlayerID;
  
       while (cin.fail()){
           cout &lt;&lt; endl &lt;&lt; "Input number" &lt;&lt; endl;
           cin &gt;&gt; PlayerID;
           return 0;
      }
  </code></pre>
  
  <p>The while loop gets activated as the "Input number" string pops up, however it's not giving me the chance to enter the correct input.</p>