. This function is used to flush any data in output stream. So this will compile but its behavior is undefined by the ANSI C standard. The fflush() function is only meant to be used on streams open for output, not input. Both fflush(stdin) and fflush(NULL), in some C libraries, will flush stdout and stderr, but this is completely unportable! Thus, it should not be used.
As mayankarpit says fflush is defined by the standard to work on output streams. If called on an input stream or a bi-directional stream thats last operation was input the behaviour is undefined.
So compiler/platforms support fflush(stdin) as an extension but using it makes the code non-portable and getting into the habit of using it could result in your getting unusual problems if you switch to a platform for which the operation is truly undefined.
There is lots of information about this on the web so do a search and it will throw up plenty of useful links like this.
Comment