Why doesn't getchar() wait for me to press enter after scanf()?

前端 未结 10 839
悲哀的现实
悲哀的现实 2020-11-22 16:22

I am learning C and I\'m using \"getchar()\" to stop the command windows so I can see the exercises am doing but it just doesn\'t work. heres a sample:

#incl         


        
10条回答
  •  [愿得一人]
    2020-11-22 17:24

    while reading other answers it just came to me that you can use scanf("%d\n",&n); instead of scanf("%d",&n); to remove new line from buffer. I haven't checked this out though.

    Hope it works :D

提交回复
热议问题