Use fflush before the scanf and that should work.