On 03/21/2011 06:19 PM, alok wrote:
> if(getchar() != EOF)
>
> what is the value of EOF
The language specification says
" EOF
.... expands to an integer constant expression, with type int and a
negative value, that is returned by several functions to indicate
end-of-file, that is, no more input from a stream"
Note that the precise value is not specified - it is frequently -1
but this is not required.
> and for what keyborad input the if statement
> will fail?
This is not a question about the language, but about the platform.
Different platforms have different ways of representing end-of-input
on a keyboard. Common examples are ctrl-z (windows) and ctrl-d (default
for at least some Unix/Linux shells). These values can be changed in
some environments (for example with the stty command on Unix/Linux).
Try reading Section 12 of the C FAQ at
http://c-faq.com - you've more
or less asked questions 12.1 and 12.1b