lkml.org 
[lkml]   [1997]   [Feb]   [22]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateSat, 22 Feb 1997 10:49:53 -0500 (EST)
FromRussell Berry <>
SubjectRe: Behavior of feof()
Okay, that's enough of that, Here is ANSI C Paragraph 7.9.10.2

The feof function

Synopsis

        #include <stdio.h>
        int feof(FILE *stream);

Description

        The feof function tests the end-of-file indicator for
        the stream pointed to by stream.

Returns

        The feof function returns nonzero if and only if the
        end-of-file indicator is set for stream.

I will also clarify that MY rgb.txt does not contain any two
word colors, nor is the first line:
! $XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp $

Now, with all that stated, there is NO logical reason that:

while(!feof(rgb))
should not behave as expected.  Is this clear now??  I was not
requesting assistance in writing a simple program, it was meant
to illustrate the odd behavior of feof().  Now, if feof is
indeed broken, I believe it is indeed a kernel related issue,
even if it isn't exactly a direct kernel function.

thanks again for the responses
On 22-Feb-97 Lars Wirzenius wrote:
>Russell Berry:
>> I'm confused by this behavior, the ANSI C standard denotes
that
>> feof() returns non-zero if and only if the end of file is
>> reached.
>
>This is wrong. feof returns true if the program has tried to
>read past the end of the file. feof doesn't predict the future,
>nor does it tell you whether you're currently at the end of the
>file. Your program doesn't try to read past the end of the file,
>because your fscanf is broken ("%s" reads a whitespace-delimited
>word, but the names of the colors can contain whitespace), so
>feof never returns true for your program.
>
>BTW, this isn't kernel related, so linux-kernel is not
approriate.
>
>-- 
>I have an aggressive junkmail filter
(http://www.iki.fi/liw/mail-to-lasu.html)
>You don't have to worry about it, since I've sent you mail.
>
>



_______________________________
Berrex Computer Solutions
Turnkey Solutions/Consulting
Software Development
http://www.albany.net/~berrex 
berrex@albany.net
\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.127 / U:0.040 seconds]
©2003-2008 Jasper Spaans