fscanf and EOF in TurboC
Michael J. Schmelzer
mjschmel at phoenix.Princeton.EDU
Fri Apr 29 15:16:46 AEST 1988
Hello everybody! I have a real problem. (?!?)
I am using Turbo C to read through a "master file" which contains
the names of all of the files to be read into my program.
I'm using fscanf(fp, "%s", filename);
Here's the problem: I don't know how to test for EOF in this
situation. For some reason, it seems that fscanf WON'T put the
file pointer at EOF when the last name is read; it will just keep
returning the last name in the file. ( feof() doesn't work!)
I've built a workaround:
the last line in the master file MUST be
END
I use the conditional
while (strcmp(filename, "END")) {
...
}
It works, but it's just not a very robust way of doing things.
Any ideas how I can my program more robust for the end user?
Is this a quirky implementation of fscanf?
Thanks a lot!!
--
"Sum Iuppiter Optimus Maximus!!"- My Latin teacher who flipped.
"Worthlessness is the root of all worthlessness." -WPRB music dept.
Mike Schmelzer mjschmel at phoenix!princeton.edu
DISLAIMER:If you think I speak for anyone but myself, you must be a lawyer.
More information about the Comp.lang.c
mailing list