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


Groups > comp.lang.c > #112418 > unrolled thread

What is the difference between (r+ and w+)

Started byChristopher <invalid@invalid.invalid>
First post2017-06-17 23:59 -0100
Last post2017-06-17 19:05 -0700
Articles 20 on this page of 65 — 17 participants

Back to article view | Back to comp.lang.c


Contents

  What is the difference between (r+ and w+) Christopher <invalid@invalid.invalid> - 2017-06-17 23:59 -0100
    Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-17 17:51 -0700
      Re: What is the difference between (r+ and w+) Christopher <invalid@invalid.invalid> - 2017-06-18 00:00 -0100
        Re: What is the difference between (r+ and w+) Jerry Stuckle <jstucklex@attglobal.net> - 2017-06-17 21:32 -0400
          Re: What is the difference between (r+ and w+) Christopher <invalid@invalid.invalid> - 2017-06-18 00:50 -0100
            Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 03:40 +0100
              Re: What is the difference between (r+ and w+) jacobnavia <jacob@jacob.remcomp.fr> - 2017-06-18 11:48 +0200
                Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 13:13 +0100
                  Re: What is the difference between (r+ and w+) Gareth Owen <gwowen@gmail.com> - 2017-06-18 16:20 +0100
              Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-18 14:49 +0100
                Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 15:46 +0100
                  Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-19 00:16 +0100
                    Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-19 05:37 +0100
                      Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-19 09:25 -0700
                      Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-19 17:35 +0100
                        Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-19 18:19 +0100
                          Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-19 20:51 +0100
                            Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-19 21:16 +0100
                    Re: What is the difference between (r+ and w+) Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-19 04:58 -0700
                      Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-19 17:43 +0100
                        Re: What is the difference between (r+ and w+) Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-19 22:16 -0700
                          Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-20 11:53 +0100
                            Re: What is the difference between (r+ and w+) Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-20 22:45 -0700
                Re: What is the difference between (r+ and w+) Good Guy <hello.world@example.com> - 2017-06-18 18:17 +0100
                  Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 18:20 +0100
                    Re: What is the difference between (r+ and w+) bartc <bc@freeuk.com> - 2017-06-18 18:27 +0100
                      Re: What is the difference between (r+ and w+) jacobnavia <jacob@jacob.remcomp.fr> - 2017-06-20 11:11 +0200
                        Re: What is the difference between (r+ and w+) bartc <bc@freeuk.com> - 2017-06-20 10:27 +0100
                        Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-20 10:54 +0100
                          Re: What is the difference between (r+ and w+) jacobnavia <jacob@jacob.remcomp.fr> - 2017-06-20 12:25 +0200
                            Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-20 12:34 +0100
                              Re: What is the difference between (r+ and w+) jameskuyper@verizon.net - 2017-06-20 05:37 -0700
                                Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-20 14:11 +0100
                                  Re: What is the difference between (r+ and w+) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-20 14:35 +0100
                  Re: What is the difference between (r+ and w+) raltbos@xs4all.nl (Richard Bos) - 2017-06-18 17:30 +0000
                    Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 21:21 +0100
                      Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 21:23 +0100
                        Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 21:47 +0100
                        Re: What is the difference between (r+ and w+) Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-18 17:01 -0400
                        Re: What is the difference between (r+ and w+) "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-19 10:41 -0400
                      Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 21:50 +0100
                      Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-18 13:52 -0700
                      Re: What is the difference between (r+ and w+) jacobnavia <jacob@jacob.remcomp.fr> - 2017-06-20 11:16 +0200
                        Re: What is the difference between (r+ and w+) raltbos@xs4all.nl (Richard Bos) - 2017-06-26 15:54 +0000
                    Re: What is the difference between (r+ and w+) Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-18 17:13 -0400
                      Re: What is the difference between (r+ and w+) Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-18 17:17 -0400
                        Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-18 15:14 -0700
                          Re: What is the difference between (r+ and w+) Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-18 18:24 -0400
                          Re: What is the difference between (r+ and w+) Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-19 04:11 -0700
                      Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 23:01 +0100
            Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-17 19:55 -0700
              Re: What is the difference between (r+ and w+) Christopher <invalid@invalid.invalid> - 2017-06-18 02:10 -0100
                Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 04:15 +0100
                Re: What is the difference between (r+ and w+) raltbos@xs4all.nl (Richard Bos) - 2017-06-18 08:31 +0000
                  Re: What is the difference between (r+ and w+) Good Guy <hello.world@example.com> - 2017-06-18 18:28 +0100
                  Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-18 11:25 -0700
                    Re: What is the difference between (r+ and w+) raltbos@xs4all.nl (Richard Bos) - 2017-06-18 19:13 +0000
                      Re: What is the difference between (r+ and w+) David Kleinecke <dkleinecke@gmail.com> - 2017-06-18 14:30 -0700
                        Re: What is the difference between (r+ and w+) Richard Heathfield <rjh@cpax.org.uk> - 2017-06-18 23:04 +0100
                Re: What is the difference between (r+ and w+) GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-06-18 10:43 +0200
                  Re: What is the difference between (r+ and w+) Jerry Stuckle <jstucklex@attglobal.net> - 2017-06-18 10:33 -0400
                    Re: What is the difference between (r+ and w+) GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-06-19 01:27 +0200
                      Re: What is the difference between (r+ and w+) Jerry Stuckle <jstucklex@attglobal.net> - 2017-06-18 21:16 -0400
        Re: What is the difference between (r+ and w+) Ian Collins <ian-news@hotmail.com> - 2017-06-18 13:45 +1200
        Re: What is the difference between (r+ and w+) Keith Thompson <kst-u@mib.org> - 2017-06-17 19:05 -0700

Page 3 of 4 — ← Prev page 1 2 [3] 4  Next page →


#112495

FromRichard Heathfield <rjh@cpax.org.uk>
Date2017-06-18 21:50 +0100
Message-ID<oi6os3$222$1@dont-email.me>
In reply to#112491
On 18/06/17 21:32, Good Guy wrote:
> On 18/06/2017 21:21, Richard Heathfield wrote:
>>
>> Agreed, but that doesn't mean printf is /in/ stdio.h.
>>
> Then why use it in a program?  For pleasure?

The inclusion of <stdio.h> into a C translation unit brings into scope a 
number of *prototypes* of standard library functions (and some useful 
type definitions and named constants).

It is the standard *library* that contains the functions, and this is 
linked, not included.

This may or may not bring you pleasure, depending on the program you write.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#112496

FromKeith Thompson <kst-u@mib.org>
Date2017-06-18 13:52 -0700
Message-ID<ln1sqhhvcg.fsf@kst-u.example.com>
In reply to#112491
Good Guy <Hello.World@Example.com> writes:
> On 18/06/2017 21:21, Richard Heathfield wrote:
>>
>> Agreed, but that doesn't mean printf is /in/ stdio.h.
>>
> Then why use it in a program?  For pleasure?

Because printf is *declared* in <stdio.h>.

The statement we're talking about, that
    All the standard functions for file input/output are contained
    in the stdio.h header file.
is at best poorly worded, and at worst simply incorrect.  If it had
instead said:
    Declarations for all the standard functions for file input/output
    are contained in the stdio.h header file.
or
    All the standard functions for file input/output are declared
    in the stdio.h header file.
it would be correct.  It seems to be typical of the sloppiness in the
book.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
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"

[toc] | [prev] | [next] | [standalone]


#112670

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2017-06-20 11:16 +0200
Message-ID<oiaour$h1s$2@dont-email.me>
In reply to#112491
Le 18/06/2017 à 22:21, Richard Heathfield a écrit :
> 
> Right. But one place you certainly *won't* see them is in <stdio.h>.

Wrong. Bartc showed the following excerpt of mingw stdio.h

__mingw_ovr
  __attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
  int printf (const char *__format, ...)
  {
    register int __retval;
    __builtin_va_list __local_argv; __builtin_va_start( __local_argv, 
__format );
    __retval = __mingw_vprintf( __format, __local_argv );
    __builtin_va_end( __local_argv );
    return __retval;
  }

[toc] | [prev] | [next] | [standalone]


#113001

Fromraltbos@xs4all.nl (Richard Bos)
Date2017-06-26 15:54 +0000
Message-ID<59512dc2.1088234@news.xs4all.nl>
In reply to#112670
jacobnavia <jacob@jacob.remcomp.fr> wrote:

> Le 18/06/2017 à 22:21, Richard Heathfield a écrit :
> > 
> > Right. But one place you certainly *won't* see them is in <stdio.h>.
> 
> Wrong. Bartc showed the following excerpt of mingw stdio.h
> 
> __mingw_ovr
>   __attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
>   int printf (const char *__format, ...)
>   {
>     register int __retval;
>     __builtin_va_list __local_argv; __builtin_va_start( __local_argv, 
> __format );
>     __retval = __mingw_vprintf( __format, __local_argv );
>     __builtin_va_end( __local_argv );
>     return __retval;
>   }

Yeah, but that's quibbling. Now you still have to define va_* and
vprintf(). You might as well say that France is part of the Netherlands
because we have a French embassy in Den Haag.

Richard

[toc] | [prev] | [next] | [standalone]


#112502

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2017-06-18 17:13 -0400
Message-ID<oi6q6d$69k$1@dont-email.me>
In reply to#112481
Good Guy wrote:

[snip]
> If you think you can run printf() without stdio.h then good luck to you.

Thanks, but I don't need luck; I know how to program. And, yes, I can "run 
printf()" without including stdio.h in my code...

  17:10 $ cat nostdio.c
  int printf(char *, ...);

  int main(void)
  {
    int i;
    for (i = 0; i < 3; ++i)
      printf("Count %d - this is a test\n",i);
    return 0;
  }
  17:10 $ cc -o nostdio -mtune=native -Wall -std=c99 -pedantic nostdio.c
  17:10 $ ./nostdio
  Count 0 - this is a test
  Count 1 - this is a test
  Count 2 - this is a test
  17:10 $ 

Q.E.D.


-- 
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

[toc] | [prev] | [next] | [standalone]


#112503

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2017-06-18 17:17 -0400
Message-ID<oi6qf1$69k$2@dont-email.me>
In reply to#112502
Lew Pitcher wrote:

> Good Guy wrote:
> 
> [snip]
>> If you think you can run printf() without stdio.h then good luck to you.
> 
> Thanks, but I don't need luck; I know how to program. And, yes, I can "run
> printf()" without including stdio.h in my code...
> 
>   17:10 $ cat nostdio.c
>   int printf(char *, ...);
> 
>   int main(void)
>   {
>     int i;
>     for (i = 0; i < 3; ++i)
>       printf("Count %d - this is a test\n",i);
>     return 0;
>   }
>   17:10 $ cc -o nostdio -mtune=native -Wall -std=c99 -pedantic nostdio.c
>   17:10 $ ./nostdio
>   Count 0 - this is a test
>   Count 1 - this is a test
>   Count 2 - this is a test
>   17:10 $

And, before the more knowledgable C programmers of the group point out my 
mistake in the prototype for printf(), you can have...

  17:14 $ cat nostdio.c
  int printf(const char *, ...);

  int main(void)
  {
    int i;
    for (i = 0; i < 3; ++i)
      printf("Count %d - this is a test\n",i);
    return 0;
  }
  17:14 $ cc -o nostdio -mtune=native -Wall -std=c99 -pedantic nostdio.c
  17:15 $ ./nostdio
  Count 0 - this is a test
  Count 1 - this is a test
  Count 2 - this is a test


-- 
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

[toc] | [prev] | [next] | [standalone]


#112507

FromKeith Thompson <kst-u@mib.org>
Date2017-06-18 15:14 -0700
Message-ID<lnwp89gcz2.fsf@kst-u.example.com>
In reply to#112503
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> Lew Pitcher wrote:
[...]
>> Thanks, but I don't need luck; I know how to program. And, yes, I can "run
>> printf()" without including stdio.h in my code...
>> 
>>   17:10 $ cat nostdio.c
>>   int printf(char *, ...);
[snip]
> And, before the more knowledgable C programmers of the group point out my 
> mistake in the prototype for printf(), you can have...
>
>   17:14 $ cat nostdio.c
>   int printf(const char *, ...);

I'd use:

    int printf(const char * restrict format, ...);

unless I had to worry about pre-C99 compilers.  It's likely I could
get away with omitting "const" and/or "restrict", but it's easier
to copy the standard declaration than to think about what changes
I can get away with.  (All this assumes I have some reason not to
use #include <stdio.h>.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
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"

[toc] | [prev] | [next] | [standalone]


#112508

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2017-06-18 18:24 -0400
Message-ID<oi6ucp$l9q$1@dont-email.me>
In reply to#112507
Keith Thompson wrote:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>> Lew Pitcher wrote:
> [...]
>>> Thanks, but I don't need luck; I know how to program. And, yes, I can
>>> "run printf()" without including stdio.h in my code...
>>> 
>>>   17:10 $ cat nostdio.c
>>>   int printf(char *, ...);
> [snip]
>> And, before the more knowledgable C programmers of the group point out my
>> mistake in the prototype for printf(), you can have...
>>
>>   17:14 $ cat nostdio.c
>>   int printf(const char *, ...);
> 
> I'd use:
> 
>     int printf(const char * restrict format, ...);
> 
> unless I had to worry about pre-C99 compilers. 

Ahhh... of course.

There seems to be a difference between the prototype published on my 
system's manpage for printf
       int printf(const char *format, ...);
and the C99 standard
       int printf(const char restrict *format, ...);

> It's likely I could
> get away with omitting "const" and/or "restrict", but it's easier
> to copy the standard declaration than to think about what changes
> I can get away with.  (All this assumes I have some reason not to
> use #include <stdio.h>.)

Also, of course.

But, then again, /I/ (like you) understand the differences between function 
libraries (like libc.so or msvcrt.dll) and #include headers while some 
others here apparently do not.  :-)

-- 
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

[toc] | [prev] | [next] | [standalone]


#112545

FromTim Rentsch <txr@alumni.caltech.edu>
Date2017-06-19 04:11 -0700
Message-ID<kfnwp88mdv2.fsf@x-alumni2.alumni.caltech.edu>
In reply to#112507
Keith Thompson <kst-u@mib.org> writes:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>
>> [to be able to use printf() without #include <stdio.h>]
>>
>>   17:14 $ cat nostdio.c
>>   int printf(const char *, ...);
>
> I'd use:
>
>     int printf(const char * restrict format, ...);
>
> unless I had to worry about pre-C99 compilers.  [...]

I would use

    extern int printf( const char *, ... );

so that I don't have to worry about whether I have to worry
about pre-C99 compilers.

[toc] | [prev] | [next] | [standalone]


#112505

FromRichard Heathfield <rjh@cpax.org.uk>
Date2017-06-18 23:01 +0100
Message-ID<oi6t10$fas$1@dont-email.me>
In reply to#112502
On 18/06/17 22:52, Good Guy wrote:
> On 18/06/2017 22:13, Lew Pitcher wrote:
>> Good Guy wrote:
>>
>> [snip]
>>> If you think you can run printf() without stdio.h then good luck to you.
>> Thanks, but I don't need luck; I know how to program. And, yes, I can "run
>> printf()" without including stdio.h in my code...
>>
>>   17:10 $ cat nostdio.c
>>   int printf(char *, ...);
>>
>>   int main(void)
>>   {
>>     int i;
>>     for (i = 0; i < 3; ++i)
>>       printf("Count %d - this is a test\n",i);
>>     return 0;
>>   }
>>   17:10 $ cc -o nostdio -mtune=native -Wall -std=c99 -pedantic nostdio.c
>>   17:10 $ ./nostdio
>>   Count 0 - this is a test
>>   Count 1 - this is a test
>>   Count 2 - this is a test
>>   17:10 $
>>
>> Q.E.D.
>>
>>
> Well then you can continue playing with your toy apps.
>
> I said you can't do anything meaningful without stdio.h

That's a strawman argument. The point at issue was whether stdio.h 
contains functions. I said it doesn't, and I'm right. I was *not* 
claiming that stdio.h has no purpose.

> but as expected,
> you guys aren't doing anything useful here apart from arguing about
> nothng.

And your strawman argument is *something*?

> IOW starting a fight in an empty room.

Neither Lew nor I started the thread; "Christopher" did. This isn't a 
fight; it's a discussion. Nor is it empty; several people have 
contributed to the thread. And nor is it a room; it's a newsgroup.

But, leaving those four objections, your sentence is otherwise correct.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#112430

FromKeith Thompson <kst-u@mib.org>
Date2017-06-17 19:55 -0700
Message-ID<lnvanuhunq.fsf@kst-u.example.com>
In reply to#112425
Christopher <invalid@invalid.invalid> 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 <invalid@invalid.invalid> 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!!
>>>
>>> <https://i.cubeupload.com/pdNkOH.png>
>> 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:
>
> <https://drive.google.com/file/d/0Bwx0lG_v1tcONExSejZWMGJaMUU/view?usp=sharing>

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  <http://www.ghoti.net/~kst>
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"

[toc] | [prev] | [next] | [standalone]


#112432

FromChristopher <invalid@invalid.invalid>
Date2017-06-18 02:10 -0100
Message-ID<oi4qno$f8j$1@gioia.aioe.org>
In reply to#112430
On 18/06/2017 03:55, Keith Thompson wrote:
> Christopher <invalid@invalid.invalid> 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 <invalid@invalid.invalid> 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!!
>>>>
>>>> <https://i.cubeupload.com/pdNkOH.png>
>>> 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:
>>
>> <https://drive.google.com/file/d/0Bwx0lG_v1tcONExSejZWMGJaMUU/view?usp=sharing>
> 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?
>

This is the book:

<http://ineasysteps.com/products-page/all_books/c-programming-in-easy-steps-4th-edition-2/>

C Programming in easy steps, 4th edition
by Mike McGrath

The guy has written many books:

<https://www.amazon.co.uk/Mike-McGrath/e/B001JS22XU/ref=dp_byline_cont_book_1>

[toc] | [prev] | [next] | [standalone]


#112433

FromRichard Heathfield <rjh@cpax.org.uk>
Date2017-06-18 04:15 +0100
Message-ID<oi4r2k$d60$1@dont-email.me>
In reply to#112432
On 18/06/17 04:10, Christopher wrote:
> On 18/06/2017 03:55, Keith Thompson wrote:
>> Christopher <invalid@invalid.invalid> 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 <invalid@invalid.invalid> 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!!
>>>>>
>>>>> <https://i.cubeupload.com/pdNkOH.png>
>>>> 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:
>>>
>>> <https://drive.google.com/file/d/0Bwx0lG_v1tcONExSejZWMGJaMUU/view?usp=sharing>
>>>
>> 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?
>>
>
> This is the book:
>
> <http://ineasysteps.com/products-page/all_books/c-programming-in-easy-steps-4th-edition-2/>
>
>
> C Programming in easy steps, 4th edition
> by Mike McGrath

Thanks. Clearly one to avoid.

> The guy has written many books:

<shrug>

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#112447

Fromraltbos@xs4all.nl (Richard Bos)
Date2017-06-18 08:31 +0000
Message-ID<594638f9.715859@news.xs4all.nl>
In reply to#112432
Christopher <invalid@invalid.invalid> wrote:

> On 18/06/2017 03:55, Keith Thompson wrote:

> > That's twice you've posted excerpts from the book without identifying
> > it.  Are you keeping the title and author secret?
> 
> This is the book:
> 
> <http://ineasysteps.com/products-page/all_books/c-programming-in-easy-steps-4th-edition-2/>

C is not a language that can be learned In Easy Steps In 24 Hours For
Dummies. It's a language for people who already know how to program, and
can deal with a professional treatment.

If you are already a decent programmer and want a good introductory book
to C, try the original: Kernighan and Ritchie's "C - The Programming
Language".
If you are not already a programmer, but want a good introductory book
to C anyway, forget it. Learn another language first, one which is
geared towards making it easy on the programmer to get things right,
rather than towards being efficient when he does. I suggest Pascal, but
some people like Python.

> C Programming in easy steps, 4th edition
> by Mike McGrath
> 
> The guy has written many books:

So has Barbara Cartland.

Richard

[toc] | [prev] | [next] | [standalone]


#112480

FromGood Guy <hello.world@example.com>
Date2017-06-18 18:28 +0100
Message-ID<oi6d72$2r6$1@news.mixmin.net>
In reply to#112447
On 18/06/2017 09:31, Richard Bos wrote:
> If you are already a decent programmer and want a good introductory 
> book to C, try the original: Kernighan and Ritchie's "C - The 
> Programming Language". If you are not already a programmer, but want a 
> good introductory book to C anyway, forget it.

A book titled "C A Software Engineering Approach" by Peter A. Darnell 
Philip  & E. Margolis is quite good IMO.

<https://www.amazon.co.uk/Peter-A.-Darnell/e/B001HCZNGQ/ref=ntt_dp_epwbk_0>

I have got the one on the right shown at the above link.





-- 
With over 500 million devices now running Windows 10, customer 
satisfaction is higher than any previous version of windows.

[toc] | [prev] | [next] | [standalone]


#112485

FromKeith Thompson <kst-u@mib.org>
Date2017-06-18 11:25 -0700
Message-ID<lna855i25d.fsf@kst-u.example.com>
In reply to#112447
raltbos@xs4all.nl (Richard Bos) writes:
[...]
> If you are already a decent programmer and want a good introductory book
> to C, try the original: Kernighan and Ritchie's "C - The Programming
> Language".

Use the second edition, not the first.  (That's probably not much of an
issue; the first edition is hard to find these days.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
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"

[toc] | [prev] | [next] | [standalone]


#112486

Fromraltbos@xs4all.nl (Richard Bos)
Date2017-06-18 19:13 +0000
Message-ID<5946d0ac.112984@news.xs4all.nl>
In reply to#112485
Keith Thompson <kst-u@mib.org> wrote:

> raltbos@xs4all.nl (Richard Bos) writes:
> [...]
> > If you are already a decent programmer and want a good introductory book
> > to C, try the original: Kernighan and Ritchie's "C - The Programming
> > Language".
> 
> Use the second edition, not the first.  (That's probably not much of an
> issue; the first edition is hard to find these days.)

I certainly agree - in fact, I wish I could find a first edition, just
for curiosity's sake, but I wouldn't recommend it to learn from these
days.

Richard

[toc] | [prev] | [next] | [standalone]


#112504

FromDavid Kleinecke <dkleinecke@gmail.com>
Date2017-06-18 14:30 -0700
Message-ID<c3ad388e-367b-447c-be67-1480e5e10dfb@googlegroups.com>
In reply to#112486
On Sunday, June 18, 2017 at 12:14:07 PM UTC-7, Richard Bos wrote:
> Keith Thompson <kst-u@mib.org> wrote:
> 
> > raltbos@xs4all.nl (Richard Bos) writes:
> > [...]
> > > If you are already a decent programmer and want a good introductory book
> > > to C, try the original: Kernighan and Ritchie's "C - The Programming
> > > Language".
> > 
> > Use the second edition, not the first.  (That's probably not much of an
> > issue; the first edition is hard to find these days.)
> 
> I certainly agree - in fact, I wish I could find a first edition, just
> for curiosity's sake, but I wouldn't recommend it to learn from these
> days.

I have a copy of the 1978 book and I can assure you - while
interesting historically - it is quite misleading about any
kind of C since the C89 standard.

[toc] | [prev] | [next] | [standalone]


#112506

FromRichard Heathfield <rjh@cpax.org.uk>
Date2017-06-18 23:04 +0100
Message-ID<oi6t6a$fas$2@dont-email.me>
In reply to#112504
On 18/06/17 23:00, Good Guy wrote:
> On 18/06/2017 22:30, David Kleinecke wrote:
>>
>> I have a copy of the 1978 book and I can assure you - while
>> interesting historically - it is quite misleading about any
>> kind of C since the C89 standard.
>
> For toy programs it must be pretty good.

Yep. It's pretty good for real programs, too. Not perfect, of course. 
But pretty darn good.

> Personally, I won't waste any time on that book

That much is obvious from your contributions to date.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#112448

FromGOTHIER Nathan <nathan.gothier@gmail.com>
Date2017-06-18 10:43 +0200
Message-ID<20170618104354.58533b3e33a8eb1654f41263@gmail.com>
In reply to#112432
On Sun, 18 Jun 2017 02:10:32 -0100
Christopher <invalid@invalid.invalid> wrote:
 
> This is the book:
> 
> <http://ineasysteps.com/products-page/all_books/c-programming-in-easy-steps-4th-edition-2/>
> 
> C Programming in easy steps, 4th edition
> by Mike McGrath
> 
> The guy has written many books:
> 
> <https://www.amazon.co.uk/Mike-McGrath/e/B001JS22XU/ref=dp_byline_cont_book_1>

A so bad track record... as usually educators are the worst experts in their field.

[toc] | [prev] | [next] | [standalone]


Page 3 of 4 — ← Prev page 1 2 [3] 4  Next page →

Back to top | Article view | comp.lang.c


csiph-web