Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.msdos.programmer > #853

Re: create new file

From "Rod Pemberton" <do_not_have@notemailnotq.cpm>
Newsgroups comp.os.msdos.programmer
Subject Re: create new file
Date 2013-03-11 03:53 -0400
Organization Aioe.org NNTP Server
Message-ID <khk2dd$rbr$1@speranza.aioe.org> (permalink)
References <75580a0d-15e3-41da-9e90-0d4f70d16e83@googlegroups.com>

Show all headers | View raw


<kerravon@w3.to> wrote in message
news:75580a0d-15e3-41da-9e90-0d4f70d16e83@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

Back to comp.os.msdos.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

create new file kerravon@w3.to - 2013-03-09 23:00 -0800
  Re: create new file kerravon@w3.to - 2013-03-09 23:48 -0800
    Re: create new file "R.Wieser" <address@not.available> - 2013-03-10 16:44 +0100
  Re: create new file "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-03-11 03:53 -0400

csiph-web