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


Groups > comp.lang.c > #76910

Re: getop() function: understanding of the code

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: getop() function: understanding of the code
Date 2015-11-22 12:45 -0800
Organization None to speak of
Message-ID <lnio4t4vbu.fsf@kst-u.example.com> (permalink)
References <385280d6-97ca-4e73-bf02-7f7fe8b8e629@googlegroups.com> <61043f85-a4ef-4c21-add4-e2ce7e8487ce@googlegroups.com> <d50a792d-8072-4662-8bf5-bcb665ed4cc4@googlegroups.com>

Show all headers | View raw


Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
> On Sunday, November 22, 2015 at 5:00:10 PM UTC, Alla _ wrote:
>> 1. the main function starts by calling getop() function; 
>>    getop(), as discussed, finishes with s[0] = 1, s[1] = 2, s[2] = '\0';
>>    the variable c at the end of getop() still holds the value of '+'
>>    hence, getop() calls ungetch() to assign the value of '+' to buf[0], 
>>    and leave buf[1] equal to some abstract value, because buf has been
>>    incremented after buf[0] has been assigned the value of '+';
>> 
> This is the difference between an array and a buffer.

No, it isn't.

Given this code:

    #define BUFSIZE 100
    char buf[BUFSIZE];

buf is an array object, both before and after values are assigned
to its elements.

Malcolm, you've made it clear that you think that what C calls an
"array object" isn't an "array" until values are stored in it.
You are misusing words that are clearly defined by the standard,
and introducing confusion.

Alla, I advise you to ignore this.  It's true that buf doesn't
contain any meaningful data until it's been assigned.  That doesn't
mean it's not an array.  (It's also perfectly reasonable to call
it a "buffer", though that term is not defined by the standard in
this context.)

[...]

-- 
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"

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-21 02:34 -0800
  Re: getop() function: understanding of the code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-21 11:00 +0000
    Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-21 04:24 -0800
  Re: getop() function: understanding of the code Barry Schwarz <schwarzb@dqel.com> - 2015-11-21 10:01 -0800
  Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-22 08:59 -0800
    Re: getop() function: understanding of the code Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-22 09:37 -0800
      Re: getop() function: understanding of the code Keith Thompson <kst-u@mib.org> - 2015-11-22 12:45 -0800
        Re: getop() function: understanding of the code Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-22 14:53 -0800
          Re: getop() function: understanding of the code Keith Thompson <kst-u@mib.org> - 2015-11-22 21:14 -0800
          Re: getop() function: understanding of the code Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-25 10:44 -0800
      Re: getop() function: understanding of the code David Thompson <dave.thompson2@verizon.net> - 2015-12-06 08:05 -0500
        Re: getop() function: understanding of the code Keith Thompson <kst-u@mib.org> - 2015-12-06 17:46 -0800
    Re: getop() function: understanding of the code Barry Schwarz <schwarzb@dqel.com> - 2015-11-22 12:03 -0800
      Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-22 23:29 -0800
    Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-23 00:02 -0800
      Re: getop() function: understanding of the code Barry Schwarz <schwarzb@dqel.com> - 2015-11-23 02:09 -0800
        Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-24 00:15 -0800
          Re: getop() function: understanding of the code Barry Schwarz <schwarzb@dqel.com> - 2015-11-24 01:46 -0800
            Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-24 01:52 -0800
          Re: getop() function: understanding of the code Philip Lantz <prl@canterey.us> - 2015-11-24 02:15 -0800
            Re: getop() function: understanding of the code Alla _ <modelling.data@gmail.com> - 2015-11-24 06:07 -0800

csiph-web