[net.lang.c] EOF with fgets

kim@emory.UUCP (Kim Wallen ) (11/01/83)

From:!sb1!sb6!emory!kim

I have been trying to use fgets() to read lines from a file inside a while
loop which tests to see if fgets() returns a NULL.  The lines are read in
and the loop seems to terminate, but I always get an illegal instruction
error at the end of main().  I have tried using fscanf() and checking for
EOF, but get the same error.  Any guidance on how I can get a line scanning
program to terminate correctly at the end of a file would be greatly
appreciated.

Kim Wallen
Psychology Dept.
Emory University
Atlanta, GA 30322


!sb1!sb6!emory!kim

futrelle@uiucdcs.UUCP (futrelle ) (11/04/83)

#R:emory:-118500:uiucdcs:27600029:000:363
uiucdcs!futrelle    Nov  3 16:59:00 1983

Try writing a program that JUST reads lines from a file and
checks.  Try omitting your variable definitions.  I had a similar
error once, and found it was because I had defined an integer
variable called read, so that whenever I used getc() the program
bombed with an illegal instruction error.  When I took out
the definitions, the program worked!

Joe Futrelle