fflush(stdin) is used to clear the buffer off the input.
I recommend you to do it on a different way, though. Sometimes the compiler may not get the fflush(stdin) right.
So, when I need the buffer to be cleared, I open up a loop to see if the user provided input the way I wanted to. In case of error, I use this one function:
while(getchar() != '\n')
There is a example of how to use it:
while(1){
if (scanf("%d", &var) == 1){
break;}
else{
while (getchar()!='\n');
continue;}
}
Basically, just put it with the conditions you want to be pleased on the scanf and that's it.
Hope it makes sense!
If there is something wrong or missing, let me know!