title: cin.clear() doesn't reset cin object
body: <p>I have the following loop. It should read numbers until <code>EndOfFile</code>, or the user input -999</p>
  
  <pre><code>int arr[100];
  
  int index;
  
  for (index = 0; index &lt; 100; index++)
  {
   cin &gt;&gt; arr[index];
   if (!cin)
   {
    cin.clear();
    index--;
    continue;
   }
   if (arr[index] == -999)
   {
       break;
   }
  }
  </code></pre>
  
  <p>When the user input an invalid thing, such as some <code>char</code>s, this loop is being repeated for ever without <code>clear</code>ing the error state or stopping.</p>