This is expected and try using fflush before scanf and you would be fine.