Date: Mon, 24 May 1999 12:06:46 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Dlanor Blytkerchan cc: djgpp AT delorie DOT com Subject: Re: freopen() In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 24 May 1999, Dlanor Blytkerchan wrote: > 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. That's because the mode string in `fopen' and `freopen' is limited to 3 characters, so "rab+" is not allowed (and unnecessary) by the ANSI C Standard. Simply use "ab+" instead of "rab+" (the `+' already means that you are allowed to both read and write to the file), and the program will work as you expect. Note that the update mode with `+' requires you to explicitly call fseek between reading and writing.