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


Groups > comp.lang.c > #17164

Re: K&R p.97

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: K&R p.97
Date 2012-02-12 14:34 +1300
Message-ID <9poj8hFr4aU6@mid.individual.net> (permalink)
References <ea85de45-665a-4098-ac47-e1771cc7b925@i2g2000vbv.googlegroups.com> <9po5asFr4aU3@mid.individual.net> <4709e3ec-3af3-4ae6-afc6-23e04d929fd2@db5g2000vbb.googlegroups.com> <9po8ufFr4aU4@mid.individual.net> <30c6f4d5-ad4e-4ca7-a19b-49f97ff90d18@m24g2000yqb.googlegroups.com>

Show all headers | View raw


On 02/12/12 11:44 AM, Tom wrote:
> On Feb 11, 10:38 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>> On 02/12/12 11:18 AM, Tom wrote:
>>
>>> On Feb 11, 9:36 pm, Ian Collins<ian-n...@hotmail.com>    wrote:
>>
>>>> Followed by a return.  This function has done its job (extracting an
>>>> integer from the stream) so it has to push the last character it read
>>>> back into the stream.  If it didn't, that character would be lost.
>>> Yes, I see your point. Thank you.
>>
>>> However, if the function is called using the for loop on p.96 then we
>>> will see the behaviour I described, won't we?
>>
>> There isn't a loop on that page.  But yes, if you where to blindly call
>> the function without checking the result you would be in a loop.
>
> Maybe we have different versions of the book. In my version there is
> the following on page 96:
>
> for (n = 0; n<  SIZE&&  getint(&array[n]) != EOF; n++)
>          ;

I do have two versions of the book, the one with my glasses on and the 
one with my glasses off!

The loop will fill the array with zeros if the input isn't numeric.  The 
loop is bound by the array size.

-- 
Ian Collins

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


Thread

K&R p.97 Tom <t.scrace@gmail.com> - 2012-02-11 12:46 -0800
  Re: K&R p.97 Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-02-11 13:25 -0800
  Re: K&R p.97 Ian Collins <ian-news@hotmail.com> - 2012-02-12 10:36 +1300
    Re: K&R p.97 Tom <t.scrace@gmail.com> - 2012-02-11 14:18 -0800
      Re: K&R p.97 Ian Collins <ian-news@hotmail.com> - 2012-02-12 11:38 +1300
        Re: K&R p.97 Tom <t.scrace@gmail.com> - 2012-02-11 14:44 -0800
          Re: K&R p.97 Ian Collins <ian-news@hotmail.com> - 2012-02-12 14:34 +1300
      Re: K&R p.97 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-11 22:52 +0000
  Re: K&R p.97 Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-02-11 17:09 -0500

csiph-web