Why does this program go in endless loop?
<p>I have such a program:</p>

<pre><code>#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;

static int pswd=0;

int main() {

    do {
        std::cout&lt;&lt;"I need your password:"&lt;&lt;std::endl;          
        std::cin&gt;&gt;pswd;
    } while (pswd!=3855);

    std::cout&lt;&lt;"Congratulations! Your password is correct! Your soul is free again!"&lt;&lt;std::endl;
}
</code></pre>

<p>And I have, may be, a stupid question.
When I enter invalid values (with non-numerical symbols or values greater then int) program goes in endless loop without reading of any information from console.</p>

<pre><code>I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
I need your password:
        ...
</code></pre>

<p>Why does this program go in endless loop?</p>
