scanf leaves a newline char behind. So if you don't have 2 getchar(), the newline will be grabbed by getchar(), and your program automatically quits.