![[C语言] getchar _C语言](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
scanf 先把缓冲区的123456拿走 然后getchar再拿走缓冲区剩下的/n
所以要先清理缓冲区
![[C语言] getchar _C语言_02](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
加一条代码清理缓冲区 ![[C语言] getchar _C语言_04](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/150919.html
![[C语言] getchar _C语言](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
scanf 先把缓冲区的123456拿走 然后getchar再拿走缓冲区剩下的/n
所以要先清理缓冲区
![[C语言] getchar _C语言_02](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
加一条代码清理缓冲区 ![[C语言] getchar _C语言_04](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/150919.html