www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/24/05:09:17

Date: Mon, 24 May 1999 12:06:46 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Dlanor Blytkerchan <dlanor AT dds DOT nl>
cc: djgpp AT delorie DOT com
Subject: Re: freopen()
In-Reply-To: <l03130301b36e2c8c8e1e@[145.98.116.154]>
Message-ID: <Pine.SUN.3.91.990524120627.14456O-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019