Mail Archives: djgpp/1999/05/24/05:09:17
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 -