Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!purdue!decwrl!uunet!bria!mike From: mike@bria.UUCP (Michael Stefanik) Newsgroups: comp.lang.c Subject: Re: fseek fread fwrite fflush Message-ID: <188@bria.UUCP> Date: 14 Apr 91 20:06:47 GMT References: <1991Apr13.003817.12434@watdragon.waterloo.edu> <1991Apr12.194547.18080@hellgate.utah.edu> Reply-To: uunet!bria!mike Organization: MGI Group International, Los Angeles, CA Lines: 26 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?