-
End of File
I'm sure you guys have had this question before... but how do you reach EOF in a statement such as...
while (getchar() != EOF)
do something;
I'm working on the exercises in K&R that want to Verify the expression getchar() != EOF is 0 or 1, and how to write a program to print the value of EOF. All the other books I've read started by teaching printf/scanf so this is a little different.
-
i haven't understood the question... but...
why while (getchar() != EOF)
and not while (c = getchar() != EOF)
you need something to get values from the file to(c)!!!
-
ASCII-charakter
Hi!
Thereīs a ASCII-character called EOF, but I donīt know its number.
klausi
-
...
The value of EOF depends on your lib i think. Or is it machine-dependant? I can't remember. K&R says it some where.
Anyways, in Windows console just press Ctrl-Z. That'll be EOF and your while loop will terminate.
On my machine printf("%d", EOF); returns -1. Try it on yours and see.
adios,
biterman.
PS: I'm sure you'll find the definition for EOF in your stdio.h file.