scanf()
returns when there is a newline buffered, but format specifiers such as
%d
to not "consume" the newline, so the next
scanf()
call returns immediately without accepting new input. That is the cause of the problem you describe - the code has other issues, such as the flawed retry code, magic numbers, and the use of the meaningless variable name
temp1
, and the fact that it is used for more than one purpose within the code, where separate usefully named variables would be appropriate. But this is not the place for code review. —
Clifford just now