title: How do I get console to loop until the right input is entered in C?
body: <p>I have a program in C simulating an ATM interaction between a user and the program by accepting choices of input to then produce an output.</p>
  
  <p>The user has to enter the value 1111, for the transaction to continue, if this isn't true, the program prints out an error and keeps requiring the user to type in the correct pin until the program reads in 1111.</p>
  
  <p>I have tried using a while loop to keep requesting for the correct value, 1111, and until it is entered, the program keeps asking the user to enter the right pin.</p>
  
  <pre><code>void main() {
  
      int pin;
  
      printf("Please enter the default pin: ");
  
      while ( pin != 1111 ) 
      {
          printf("Invalid input ");
          printf("Please enter the default pin again: ");
          scanf("%d", &amp;pin);
  
          if (pin == 1111) 
          {
              //The program continues
          }
  
      }     
  }
  </code></pre>
  
  <p>Every time I type in the wrong pin, it asks for the pin one more time and then crashes with an error that the program had stopped working. I think I'm causing an infinite loop but I'm not so sure what's going on.</p>