Re: just got myself a copy of K&R...

From: Jirka Klaue (jklaue_at_ee.tu-berlin.de)
Date: 11/08/03

  • Next message: nullptr: "Re: RLE code review"
    Date: Sat, 08 Nov 2003 14:11:21 +0100
    
    

    Richard Heathfield wrote:
    > Jirka Klaue wrote:
    >> Richard Heathfield wrote:
    ...
    >>>It wouldn't, ever. EOF is what happens when there is no more input.
    >>
    >>This is the intent, but I think it is not guaranteed, nevertheless.
    >>
    >>for (;;) {
    >> c = getchar();
    >> if (feof(f) || ferror(f)) break;
    ...
    > So if your point was that EOF can be returned for a reason other than
    > I'm-all-out-of-data, then you're correct - it can also be returned on
    > error. Otherwise, I am not sure what your point is.

    If all integer types are 32bit wide and CHAR_MAX == INT_MAX, EOF could
    be normal data too. That's why my point was, as you noted, that EOF
    could be returned for some other reason than end-of-file. Only that I
    did have one more reason in mind. :-)
    The only reliable method to check for end-of-file seems to be feof(),
    doesn't it?

    Jirka


  • Next message: nullptr: "Re: RLE code review"

    Relevant Pages

    • Re: End of Stream
      ... an end-of-file (EOF) that will mess up the following lines. ... I know that, and you know that, but the source of the code the OP was quoting had to have had that line there for a reason, and that was the only reason it could have been there. ...
      (comp.lang.java.help)
    • Re: just got myself a copy of K&R...
      ... Jirka Klaue wrote: ... > your code is exactly the same as the code using EOF. ... well obviously EOF is not set to -1 because the program never stops, ... testing for ARRAY, to make sure I didn't input a value past the last ...
      (comp.lang.c)
    • Re: Dynamic arrays
      ... Jirka Klaue wrote: ... > Rick wrote: ... >> I'm trying to use a dynamic array but for some reason it won't work. ...
      (comp.lang.c)
    • Re: just got myself a copy of K&R...
      ... > Jirka Klaue wrote: ... > EOF is guaranteed to be negative, and of type int, and to mean "no ... > for EOF. ... > Depends on your definition of reliable - feof() only returns true ...
      (comp.lang.c)