GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 437 of 453    Print  
fflush() in Multiple Scanf calls
What is the requirment of using fflush() in multiple scanf calls.


  
Total Answers and Comments: 3 Last Update: September 02, 2009     Asked by: Gaurav Kumar 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Bajrang ASthana
 
Fflush is mainly used to cleanup all pipelines and buffer which are used during the storage of data or writing the data; it is necessary because it may block pipelines and may be responsible undesired output. It is good programming approach that you flush pipeline after writing data, in case of Java programming it is must to flush data otherwise it will not go properly into destination file.

Above answer was rated as good by the following members:
John Tinnon, chandrakumar.g, Ajay Kanse
September 26, 2008 03:21:14   #1  
Bajrang ASthana Member Since: September 2008   Contribution: 1    

RE: fflush() in Multiple Scanf calls
Fflush is mainly used to cleanup all pipelines and buffer which are used during the storage of data or writing the data; it is necessary because it may block pipelines and may be responsible undesired output. It is good programming approach that you flush pipeline after writing data in case of Java programming it is must to flush data otherwise it will not go properly into destination file.
 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
October 10, 2008 10:50:19   #2  
raman0.balakrishnan0 Member Since: October 2008   Contribution: 1    

RE: fflush() in Multiple Scanf calls
scanf could leave some characters in the input stream based on what is specified in
the format specifier says " s" etc. The fflush is done to take care that the subsequent scanf does not read these extraneous characters.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
September 01, 2009 21:19:42   #3  
suman680 Member Since: February 2009   Contribution: 1    

RE: fflush() in Multiple Scanf calls

When we take some name age class from user using scanf then at first when we take name and after age then some time the age place is skip and user can not assigned any value there. Reason behind it only is buffer. After giving name by user there some change in buffer to clear this buffer we can use fflush().


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape