Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: What is the difference between (r+ and w+) Date: Sat, 17 Jun 2017 19:55:05 -0700 Organization: None to speak of Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="1d5a24d016722a50a74735015b7fb40e"; logging-data="25040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18yuZng3ckgA6qgmOhVPhDR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PAorFGfw7GEnYyAFn0PBwqzagcw= sha1:6e3cLT1Rbix7/V3UvCcihTtWhKA= Xref: csiph.com comp.lang.c:112430 Christopher writes: > On 18/06/2017 02:32, Jerry Stuckle wrote: >> On 6/17/2017 9:00 PM, Christopher wrote: >>> On 18/06/2017 01:51, Keith Thompson wrote: >>>> Christopher writes: >>>>> r+ Opens a text file to read from or write to >>>>> w+ Opens a text file to write to or read from >>>>> >>>>> It looks exactly the same thing to me!! >>>> What reference did you use? Here's what the C standard says >>>> (N1570 7.21.5.3p3): >>>> >>>> r+ open text file for update (reading and writing) >>>> w+ truncate to zero length or create text file for update >>>> >>> This is a copy from the book!! >>> >>> >> Yes, but although your book isn't very clear on this (at least not what >> you posted - I don't know what the rest of the text says), these are >> extensions of the "r" and "w" modes. >> >> "r" opens an existing file to read, while "r+ does the same but also >> allows writing. >> >> "w" opens a file to write. If one exists, it is truncated; otherwise a >> new file is created. "w+" does the same but also allows reading. >> > > The book is pretty simple. It is for newbies like me and it gives step > by step instructions of how to do things. See this two page doc from > the book re files creation: > > Does the book's author think that beginners don't need to know that "w+" truncates an existing file? That's twice you've posted excerpts from the book without identifying it. Are you keeping the title and author secret? -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"