what happens when you input things like 12ab to scanf(“%d”,&argu)?

前端 未结 5 1910
无人共我
无人共我 2020-12-11 07:08

I came across this problem when I want to check what I input is number. The scanf function will return 1 if I successfully input a number. So here is what I wro

5条回答
  •  春和景丽
    2020-12-11 07:40

    Call scanf("%*[^\n]\n") inside the loop. This should be enough to discard anything associated with the cache.

提交回复
热议问题