What are the differences in EOF & FEOF in the

Discussion in 'C Programming' started by 2005, Apr 8, 2008.

  1. 2005

    2005 Guest

    context of a C program reading from a file?

    I know its end of file but ...not sure?
     
    2005, Apr 8, 2008
    #1
    1. Advertising

  2. 2005 wrote:
    > context of a C program reading from a file?


    Please don't ask your real question in the subject line.

    FEOF is not mentioned in the C standard.

    > I know its end of file but ...not sure?


    Get yourself a decent C text book. C is not a good
    language to learn by asking 20 (000) questions.

    --
    Peter
     
    Peter Nilsson, Apr 8, 2008
    #2
    1. Advertising

  3. 2005

    2005 Guest

    On Apr 7, 11:06 pm, Peter Nilsson <> wrote:
    > 2005 wrote:
    > > context of a C program reading from a file?

    >
    > Please don't ask your real question in the subject line.
    >
    > FEOF is not mentioned in the C standard.
    >
    > > I know its end of file but ...not sure?

    >
    > Get yourself a decent C text book. C is not a good
    > language to learn by asking 20 (000) questions.
    >
    > --
    > Peter


    I do have several books - I saw a code online with EOF when reading
    from a file.
    That's why

    I read the book too but would like a crisp answer

    I appreciate a tip.
     
    2005, Apr 8, 2008
    #3
  4. 2005

    2005 Guest

    On Apr 7, 11:47 pm, Richard Heathfield <> wrote:
    > 2005 said:
    >
    > <snip>
    >
    > > I do have several books - I saw a code online with EOF when reading
    > > from a file.
    > > That's why

    >
    > > I read the book too but would like a crisp answer

    >
    > K&R2 provides a crisp answer on page 16.
    >

    I have K&R - not sure if there had been a "2"

    EOF - a distinctive value when there is no more input, a value that
    cannot be confused with any real character. This value is called
    EOF, for ``end of file''.
    FILE *in = fopen("myfile.txt", "r"); // Open myfile.txt read-only
    while((myChar=fgetc(in)) != EOF) {
    ---------
    ---

    feof is to distinguish between cases where a stream operation has
    reached the end of a file and cases where the "EOF" (End Of File)
    error message has simply been returned as a default error message,
    without the end of the file actually being reached.

    while(!feof(my_file)) {
    /* [...End of file not reached, do something with it...] */
    }
    -----
    --

    So what is the difference when it comes to application?
     
    2005, Apr 8, 2008
    #4
  5. 2005 wrote:
    > I have K&R - not sure if there had been a "2"
    >
    > EOF - a distinctive value when there is no more input, a value that
    > cannot be confused with any real character. This value is called
    > EOF, for ``end of file''.
    > FILE *in = fopen("myfile.txt", "r"); // Open myfile.txt read-only
    > while((myChar=fgetc(in)) != EOF) {
    > ---------
    > ---
    >
    > feof is to distinguish between cases where a stream operation has
    > reached the end of a file and cases where the "EOF" (End Of File)
    > error message has simply been returned as a default error message,
    > without the end of the file actually being reached.
    >
    > while(!feof(my_file)) {
    > /* [...End of file not reached, do something with it...] */
    > }
    > -----
    > --
    >
    > So what is the difference when it comes to application?


    What do *you* think the difference is? Post your answer here, and we
    will tell you if you are right or not, and if you are wrong, we will
    tell you where your mistake is.

    I suggest this for two reasons:

    1) It is *much* more effective to learn by doing than by being lectured.
    2) It's difficult to see which bit is confusing you. You have already
    asked the difference between feof() and EOF, and Richard gave you this
    answer. If you just ask the same question again, we don't know how to
    make it any clearer.

    Philip
     
    Philip Potter, Apr 8, 2008
    #5
  6. 2005 <> writes:
    > On Apr 7, 11:47 pm, Richard Heathfield <> wrote:
    >> 2005 said:
    >>
    >> <snip>
    >>
    >> > I do have several books - I saw a code online with EOF when reading
    >> > from a file.
    >> > That's why

    >>
    >> > I read the book too but would like a crisp answer

    >>
    >> K&R2 provides a crisp answer on page 16.
    >>

    > I have K&R - not sure if there had been a "2"


    K&R2 is the second edition. The first edition is mostly of historical
    interest; it describes a largely obsolete version of the language. If
    you have the first edition, invest in a copy of the second.

    > EOF

    [snip]

    > feof is to

    [snip]

    > So what is the difference when it comes to application?


    The comp.lang.c FAQ is at http://www.c-faq.com. Read section 12.
    Then read the rest of it.

    --
    Keith Thompson (The_Other_Keith) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Apr 8, 2008
    #6
  7. On Tue, 08 Apr 2008 00:52:07 -0700, Keith Thompson <>
    wrote:

    > 2005 <> writes:


    > > I have K&R - not sure if there had been a "2"

    >
    > K&R2 is the second edition. The first edition is mostly of historical
    > interest; it describes a largely obsolete version of the language. If
    > you have the first edition, invest in a copy of the second.
    >

    Which you might be able to finance by selling K&R1 to a collector. <G>

    And get the errata at http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html
    - formerly david.thompson1 || achar(64) || worldnet.att.net
     
    David Thompson, Apr 21, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok Redgormor

    feof usage

    Mantorok Redgormor, Sep 20, 2003, in forum: C Programming
    Replies:
    28
    Views:
    1,151
    Dave Thompson
    Sep 29, 2003
  2. Kobu
    Replies:
    10
    Views:
    640
    Keith Thompson
    Mar 4, 2005
  3. rCs

    EOF vs. feof() and ferror()

    rCs, Oct 31, 2006, in forum: C Programming
    Replies:
    8
    Views:
    1,774
    Barry Schwarz
    Nov 1, 2006
  4. SpreadTooThin

    ifstream eof not reporting eof?

    SpreadTooThin, Jun 13, 2007, in forum: C++
    Replies:
    10
    Views:
    709
    James Kanze
    Jun 15, 2007
  5. Jan Burse
    Replies:
    67
    Views:
    1,083
    Jan Burse
    Mar 14, 2012
Loading...

Share This Page