EOF
is a macro which expands to an integer constant expression with type int
and an implementation dependent negative value but is very commonly -1.
'\0'
is a char
with value 0 in C++ and an int
with the value 0 in C.
The reason why printf("%d",a==EOF);
resulted in 1
was because you didn’t assign the value EOF
to a
. Instead you checked if a
was equal to EOF
and since that was true (a == -1 == EOF
) it printed 1
.