2 candidates
Your terminal I/O has an unneeded local echo turned on. Thus an OS issue, not a issue of this program.
Missing
;
at end ofwhile()
invokes expected results. The code as posted should simple read some input and then immediately exit. This is not as the OP recounts. Suspect it is a mis-transcription of the problem.
[edit] Now see all of @alk solution. Certainly something is in the OP's real code that is not visible in the post -maybe due to mixed\r
and\r\n
and\n
?// Was it a typo that the OP did not have a
;at the end?
while (scanf("%d", &n) > 0)