what does fflush do??

what fflush(stdin)means??

Recommended Answers

It flushes the input buffer i.e. writes everything to the output stream.
Some systems don't write all the input buffer contents to the screen until newline character is encountered so to write everything to the screen fflush() can be used.

Jump to Post

All 2 Replies

It flushes the input buffer i.e. writes everything to the output stream.
Some systems don't write all the input buffer contents to the screen until newline character is encountered so to write everything to the screen fflush() can be used.

what fflush(stdin)means??

It means whatever the implementation chooses it to mean. The C standard says that calling fflush() with an input stream is undefined. However, many implementations choose to make it read and discard unread input from the stream in a manner similar to this explicit loop:

while (getchar() != '\n')
    ;

You cannot rely on that behavior, but it can be useful if all targeted implementations support it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.