while (getchar () != '\n' );
<p>I have the following for loop, I am prompting the user to enter a 4 digit pin and hit enter. Can someone explain to me what the while loop is really doing because I don't fully understand it. </p>

<pre><code>//user input for pin
for(i = 0; i &lt; PIN_LENGTH; i++)
{
    printf("Enter digit %d of your PIN: ", i);
    user_pin[i] = getchar();
    while (getchar() != '\n'); //what is this line doing??
}
</code></pre>