fseek fread fwrite fflush
Michael Stefanik
mike at bria.UUCP
Mon Apr 15 06:06:47 AEST 1991
In an article, Thomas Murphy writes:
|In an article, Andrew Walduck writes:
||I've got a question about fseek, fread, fwrite and fflush....
||Is it necessary to do the following?
||fflush(fp);
||fseek(fp....);
||fwrite(fp...);
|
|You are always safest if you flush streams btwn io phases...this goes
|for io to the console or to some file...thus if you have been reading
|you should flush before writing and again before returning to reading
|again and in addition flush before closing.....sounds like rules of
|the john eh?
This seems to have the same effect as knocking on wood, or throwing salt
over one's shoulder -- if such superstitious fflush()'s make you feel
better, then do so by all means. The only situation that I have found it
to be useful is dumping the stream before I do a raw read on a tty.
However, I doubt the merit of doing them in the name of "safety". Certainly,
a fflush() before a close is redundant.
--
Michael Stefanik, MGI Inc, Los Angeles | Opinions stated are never realistic
Title of the week: Systems Engineer | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
If MS-DOS didn't exist, who would UNIX programmers have to make fun of?
More information about the Comp.lang.c
mailing list