+ 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
1 Réponse
+ 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...