Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!tymix!cirrusl!ss168!dhesi From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: fseek fread fwrite fflush Message-ID: <3054@cirrusl.UUCP> Date: 15 Apr 91 19:32:19 GMT References: <1991Apr13.003817.12434@watdragon.waterloo.edu> <1991Apr12.194547.18080@hellgate.utah.edu> <188@bria.UUCP> Sender: news@cirrusl.UUCP Organization: Cirrus Logic Inc. Lines: 22 Somebody writes: Certainly, a fflush() before a close is redundant. Peculiar counterexample follows. In an MS-DOS environment, to set the timestamp on a file, you must first open it and get a file descriptor (file handle) to it. So, if you have just finished writing data to an open file and want to leave its timestamp set to some special value, the safe sequence is: if (fflush(f) != 0) { handle error; } set_timestamp(fileno(f), time_value); (void) fclose(f); If the fflush is not done, the fclose can write data to the file, overriding the timestamp that has been set. -- Rahul Dhesi UUCP: oliveb!cirrusl!dhesi