<
kerr...@w3.to> wrote in message
news:75580a0d-15e3-41da...@googlegroups.com...
> Is it normal for a C runtime to treat an
> fopen of "w" as "check to see if there is
> an existing file before creating one?
According to Harbison and Steele's "C: A Reference Manual", 3rd
edition, "w" is supposed to either create a new file or truncate
an existing file. "w+" truncates too. "wb" is not listed.
ISO C99 says "w+" is to "truncate to zero length or create text
file for update" in 7.19.5.3 "The fopen function" subsection 3.
"w", "w+", and "wb" all truncate.
ISTM, that the "truncation" feature of "w", "wb", and "w+", would
imply "w" is supposed to check the existence of the file in order
to delete it if it exists, i.e., "truncate"...
So, I'd say: "Yes." Although, I've not actually tested any C
libraries to check what they actually do for this situation.
FYI, current ISO C "rough draft" specifications are available
online. And, there is comp.lang.c if you dare go there...
Rod Pemberton