Scrivi così

while (getchar() != '\n');

per svuotare il buffer.