Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!ukc!acorn!moncam!emmo From: emmo@moncam.co.uk (Dave Emmerson) Newsgroups: comp.os.msdos.programmer Subject: Re: Turbo C++ fopen() & fflush() Summary: fflush doesn't Message-ID: <1020@marvin.moncam.co.uk> Date: 25 Nov 90 19:47:58 GMT References: <1778@mts.ucs.UAlberta.CA> Organization: Monotype ADG, Cambridge, UK Lines: 29 In article <1778@mts.ucs.UAlberta.CA>, userBARD@mts.ucs.UAlberta.CA (Barry Ard) writes: > I'm using TC++ 1.0 and am fopen()'ing a file that I write to using > fwrite(), I then do an fflush(), and as a test I reboot via the 3 finger > salute (ctrl-alt-del). When I check the file the fwrite() didn't > happen. Heh, I got burned by that one too. Problem is, fflush doesn't flush the DOS buffers to disk, so you need to do : FILE *stream ; int fhandle ; .... fflush(stream) ; fhandle = dup(fileno(stream)) ; close(fhandle) ; .... Its messy, but it'll fix it for you. Note that stream remains open, but the buffers have been flushed, and the FAT updated. ATB, Dave E.