+ 1

What is the use of fflush(stdin) in c programming(i know here c is not included)

i was working on a switch program and i got stuck by some errors,i concerned it to my mentor but he just only told me to use fflush(stdin). But i can't understand it why it's used. I am confusing about it in internet so plz help me to solve my confusion... thanks

28th Jul 2017, 8:31 AM
Ashish Negi
Ashish Negi - avatar
1 ответ
+ 2
As the word suggests it allows you to flush your stdin (standard input), that is to say your keyboard. When you use a program and give input by keyboard, the keys you press are stored in a kind of box (ideally) and they wait to be consumed by some function or someting like that... If you press some keys while using a programm and nothing consume them , they stay there and if you want to delete them from there, you can use fflush(stdin) function which clear the box the same way your toilet does when you flush it...
28th Jul 2017, 9:37 AM
2_3rr0r5
2_3rr0r5 - avatar