By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,543 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

What is the exact functionality of fflush(stdin) or fflush(stdout)?

P: 28
many times i encountered these two functions,especially i have used them in socket programming in unix environment
but i just have a vague idea regarding functionality of those two functions
they are used to clear input and output buffer

but am not having a faintest idea regarding how they actually work

please help me
thanks a lot in advance
Nov 12 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
How they work is implementation defined and on many platforms fflush(stdin); is undefined behaviour and is defined by the standard as such.

A few platforms provide fflush(stdin); as an extension to the standard but if you are writing portable programs you should avoid fflushing an input stream or an inout stream after it has been used for input.

fflush(stdout); ensures that all buffered output for stdout is written to stdout before the function returns. Like I said how it is done is platform dependent and I would not worry about it. If you do get an answer it will only apply to the platform that the answer is given for.
Nov 13 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.