🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3174

Re: Turbo C++ fopen() & fflush()

#3174
From: Dave Emmerson
Date: Sun, 25 Nov 1990 19:47
29 lines
1175 bytes
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.
Technical Details
Message-ID: <1020@marvin.moncam.co.uk>
Path: arc1-ca.pugleaf.net!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
References: <1778@mts.ucs.UAlberta.CA>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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