troubleshooting Question

About the use/ need of fflush .....

Avatar of Ashim
Ashim asked on
6 Comments1 Solution1999 ViewsLast Modified:
Hello there,

Could any1 here tell me when exactly fflush is used?
I do understand that fflush is used to clear a stream fflush(stdin) clears the buffer so functions like scanf / getchar can get the right input ?

If I say printf("\n");
         and then scanf("%c",&character)
then I should put fflush(stdin) to get the right input..... but do I have to uses fflush EACH TIME I use scanf ?? In that case, why did not the guy who designed C (Mr. Denis Ritchie was it ? ) make fflush a part of scanf ??

In case you find the above confusing,I rephrase it once again....

When EXACTLY do we have to use fflush ? Is it that we have to precede each scanf by an fflush(stdin) statement?

F. Dominicus

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros