X-Sender: dlanor AT mail DOT dds DOT nl Message-Id: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Mon, 24 May 1999 00:18:04 +0200 To: djgpp AT delorie DOT com From: Dlanor Blytkerchan Subject: freopen() Reply-To: djgpp AT delorie DOT com in an ANSI C program, I am attempting to create and open a read/write binary file as follows: I use fopen() to open the file in mode "ab". This should leave the file alone if it already exists; After this, I use freopen() to open the same file in mode "rab+", which - to my knowledge, should allow me complete read/write access to the newly created file. Here's the prob: this works fine if the file already exists: I get the access i wanted in the first place. If the file did not exist in the beginning, the file is created but when I attempt to write I get an ENOENT error, which seems odd to me, as the file has just been created. My question: is the method I am using just too slick for DJGPP, is it an error in my warped mind, or is there something really wrong here? Here's an overview in code-form: FILE *filename; filename = fopen("foo", "ab"); if ((filename = freopen("foo", "rab+", filename)) == NULL) { perror("foo"); } // if The reason I'm doing it like this in the first place, is that, though a in the mode should create the file if it isn't there, rab+ results in ENOENT if the file isn't there. This _only_ produces an error when, immediatly after this operation, I try to write. If anyone can point out my mistake - or GCCs - I'd be much obliged.. Greetz! Dlanor ==================================================================== * Dlanor Blytkerchan * * * * * * | | | * * RLSystems software & support \_/-\_/ * -------------------------------------------------------------------- * Sites by Dlanor Blytkerchan you should visit: * * The Hazardous Domain: * * * * Including: * * - The Hazardous Area: VGA Planets game site * * - The Catacombes: VGA Planets support site * * - The TKon Empire: Rulers of The Echo Cluster * * - The Insatiables: an undefeated VGA Planets team * * and: * * - The RLSystems main page: miscelanious software * * - The Third Domain: Dlanor's personal site * * * * The Hazardous Forum - Bulletin & chat * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Other sites you should visit: * * The Holodeck: a VGA Planets site by Andrew Sartori * * * * The Last Wave: a VGA Planets site by Alan L. Warchuck * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * These sites are on The Hazardous LinkList.. * -------------------------------------------------------------------- * PGP public key is available at * * * ====================================================================