You need to flush the input buffer: add the following after the
scanf
call:
while ((c = getchar()) != '\n' && c != EOF)
continue;
Note the variable
c
should be declared above as
int c;
. I also suggest you add newline characters (
\n
) to the end of all your
printf
strings.