A
alok
if(getchar() != EOF)
what is the value of EOF and for what keyborad input the if statement
will fail?
what is the value of EOF and for what keyborad input the if statement
will fail?
if(getchar() != EOF)
what is the value of EOF and for what keyborad input the if statement
will fail?
if(getchar() != EOF)
what is the value of EOF and for what keyborad input the if statement
will fail?
In some systems, notably MS-DOS, end of file was indicated by aWhat's an "EOF character" ?
The value of EOF is EOF, which is a negative value of type (int), which
cannot be represented in an (unsigned char). The exact value is up to
the implementation, and you should try not to know what it is, because
if you know the value you're liable to write code which expects that value,
and that code will fail when you try to run it on a different platform.
I took it as being shorthand forWhat's an "EOF character" ?
Be wary anytime anyone tells you that you shouldn't know something. This is
very much the stance of the medieval Church.
if(getchar() != EOF)
what is the value of EOF
and for what keyborad input the if statement
will fail?
That isn't what Morris said ...
Information hiding is a good ecclesiastical as well as programmingBe wary anytime anyone tells you that you shouldn't know something. This is
very much the stance of the medieval Church.
Be wary anytime anyone tells you that you shouldn't know something.
This is
very much the stance of the medieval Church.
If you want to know what EOF is on your system, try this:
$ printf '#include <stdio.h>\nmain() {printf("EOF = %%d\\n",EOF);return
0;}'|gcc -xc - && ./a.out && rm ./a.out
which displays EOF = -1 on my system.
I think even the most experienced CLC word parser would be very hard-pressed
to explain how Morris didn't say that you shouldn't know the value of EOF..
I took it as being shorthand for
"the keystroke (combination) which when entered on a keyboard
(or similar input device) indicates to the operating system
that end of file has been reached. This will be represented
by the C support libraries by delivering the EOF value as the
result of a read from this device."
Say you seeI don't see how knowing the exact value of EOF helps you in any way.
Information hiding is a good ecclesiastical as well as programming
principle.
If you give people information they don't need they might misuse it,
bringing down the entire system.
Tom said:I don't see how knowing the exact value of EOF helps you in any way.
Tom said:But more fundamental, how does it *hurt* to know what it is?
Fine, but I wouldn't allow my developers to use -1 in place of EOF.
In a similar vein, I doubt if it helps to know pi to more than 20 places.
Except, that pi by definition cannot change. EOF is defined as "a
negative integer." it could be -2 for all it matters...
But many people know how to find or even compute this value. Some people
just want to know for the sake of knowing - I am one of those people. Of
course they should be warned about the hazards of actually using the value.
Then look it up, but don't presume that knowing the value of EOF helps
you develop your application.
I liked the quote about the church; unfortunately I think there have been
threads where the quote would have been a better fit rather than this
particular thread.
That's just Kenny trying to be grandios.
Tom
Tom St Denis said:That's just Kenny trying to be grandios.
Be wary anytime anyone tells you that you shouldn't know something.
This is very much the stance of the medieval Church.
Sherm Pendley said:In general, I think it's poor practice to "look behind the curtain" of
whatever level of abstraction you happen to be working at. At any given
level, there are going to be implementation details that simply don't
matter to the task at hand, and concerning one's self with them only
serves as an unnecessary distraction.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.