Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The fflush function 1

Status
Not open for further replies.

mattias1975

Programmer
Jul 26, 2004
36
SE
Hello!

When should i use the fflush function?
When i read characters from the keyboard, from a file?
Should i call it before i call for example getchar or after?
What does it actualy do?
 
> When should i use the fflush function?
Between writing a file and reading a file is the most common use.

> When i read characters from the keyboard, from a file?
> Should i call it before i call for example getchar or after?
If you're thinking of calling fflush(stdin); then you're way off base.
fflush() only works for
- output streams
- update streams where the most recent action was output.
These are the only options supported by the standard.

Some compiler vendors appear to do something for stdin, but beware that such use is NON-standard. So don't complain when it stops working.

> What does it actualy do?
Read the manual page for fflush()

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top