Why does scanf appear to skip input?

前端 未结 7 1529
忘了有多久
忘了有多久 2020-12-19 13:17

I am confused about scanf\'s behaviour in the following program. scanf appears to input once, and then not input again, until a stream of characters is printed.

Belo

相关标签:
7条回答
  • 2020-12-19 14:20

    You are ignoring the return value. See what the manual says about scanf(3):

    RETURN VALUE
    These functions return the number of input items successfully matched and assigned, which can be fewer than provided for, or even zero in the event of an early matching failure.

    It fails matching an integer.

    0 讨论(0)
提交回复
热议问题