title: Why does this code involving cin skip getline even with cin.ignore()?
body: <p>The following code works as intended for the first two getlines and after you input the CC variable it goes into an infinite loop skipping the getlines and not waiting for input.</p>
  
  <p>Here is a sample run:</p>
  
  <p>Enter card holder name (or quit): John Doe</p>
  
  <p>Enter CC number: 1234 1234 1234 1555</p>
  
  <p>// code outputs the other couts but does not wait for input of getline. and reiterates the cout statements. cin.ignore does not seem to help or cin.clear()</p>
  
  <p>Code:</p>
  
  <pre><code> int main(int argc, char* argv[]) {
  
      char CCName[64];    //cardholder name
      char  CCNumber[16]; //credit card number
      char Expiration[8]; //expiration date 
      float Amount;     
  
  
      while (true) {
  
          /* input processing block */
  
          //gather card holder name
          cout &lt;&lt; "\nEnter card holder name (or quit): ";
          cin.getline(CCName, 64);
  
          //quit command processing 
          if (strcmp(CCName, "quit") == 1) {
              cout &lt;&lt; "\nYou successfully terminated the program\n";
              //~ close(sockfd); //close socket
              exit(EXIT_SUCCESS);
          }
  
          //gather credit card number
          cout &lt;&lt; "\nEnter CC number: ";
          cin.getline(CCNumber, 16);
          //error checking
          if (strlen(CCNumber) != 15 &amp;&amp; strlen(CCNumber) != 16) {
              cout &lt;&lt; "\nCredit card number must be 15 to 16 digits, try again: ";
              cin.getline(CCNumber,16);
          } 
  
          //gather expiration date
          cout &lt;&lt; "\nEnter expiration: ";
          cin.ignore();
          cin.getline(Expiration, 7);
          //error checking
          if (strlen(Expiration) != 7) {
              cout &lt;&lt; "\nExpiration date format mm/yyyy. Try again: ";
              cin.getline(Expiration, 7);
          }
  
          //gather amount
          cout &lt;&lt; "\nEnter amount: ";
          cin &gt;&gt; Amount;
  }
  
     return 0;
  }
  </code></pre>