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


Groups > comp.lang.c > #22726

Re: fread/fwrite 2

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: fread/fwrite 2
Date 2012-06-25 14:11 -0700
Organization None to speak of
Message-ID <lnwr2v5c7p.fsf@nuthaus.mib.org> (permalink)
References (3 earlier) <ea3bef2c-b092-4140-899f-153efa3c4169@l32g2000yqc.googlegroups.com> <0.3bdff12a5d8512405d1c.20120624215804BST.87fw9kmnqb.fsf@bsb.me.uk> <e60de647-1c86-4a2e-a7e6-aff679edf8e8@t8g2000yqd.googlegroups.com> <0.aa27a393b4a0f5894860.20120625021534BST.87395kmbt5.fsf@bsb.me.uk> <9317823d-34f7-46c6-917b-98ad0252837e@37g2000yqu.googlegroups.com>

Show all headers | View raw


Bill Cunningham <me26us@yahoo.com> writes:
> On Jun 24, 9:15 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
>> >> There's a bug here.  What happens when there is a read error?
>>
>> > What's exactly wrong here? Should I maybe have used
>> > while(ferror(fpi)&&!feof(fpi)); ?
>>
>> Not quite.  You need to stop when there is an error (at least when there
>> is a read error) because you can't rely on eof(fpi) becomming true.
>
> What could I do then? Test for ferror and do something else with
> feof ?

For the benefit of other readers:

First check the value returned by fread() or fwrite(). If that result
indicates an error, *then* call feof() and/or ferror() to get more
information.

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"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 | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-23 13:31 -0700
  Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-23 15:18 -0700
    Re: fread/fwrite 2 Ike Naar <ike@sverige.freeshell.org> - 2012-06-23 22:42 +0000
      Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-24 12:51 -0700
        Re: fread/fwrite 2 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-24 21:58 +0100
          Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-24 14:36 -0700
            Re: fread/fwrite 2 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-25 02:15 +0100
              Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-25 13:15 -0700
                Re: fread/fwrite 2 Keith Thompson <kst-u@mib.org> - 2012-06-25 14:11 -0700
                Re: fread/fwrite 2 nick_keighley_nospam@hotmail.com - 2012-06-26 00:35 -0700
                Re: fread/fwrite 2 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-26 13:30 +0100
      Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-25 16:35 -0700
        Re: fread/fwrite 2 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-26 03:18 +0100
          Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-26 13:08 -0700
  Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-23 15:32 -0700
    Re: fread/fwrite 2 John Gordon <gordon@panix.com> - 2012-06-24 14:01 +0000
      Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-24 11:32 -0700
        Re: fread/fwrite 2 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-24 20:06 +0100
          Re: fread/fwrite 2 Bill Cunningham <me26us@yahoo.com> - 2012-06-24 12:25 -0700

csiph-web