I've been told that whenever you work with bytes, you should declare your variables as unsigned chars. In Windows' data types, BYTE is declared as an unsigned char.
My questions:
Why?
Unsigned is a representation of integers from 0 to 255 and signed 128 to -127.
If that's the case, then how is EOF in binaries (-1) caught?
EOF is declared in stdio.h as a -1 #define macro.
char
issigned
orunsigned
. Also,EOF
is anint
and not achar
. If you assignEOF
to achar
and compare it to theint
valueEOF
they will not match, because the compiler will extend thechar
to0x000000ff
which is not the same as theint
value0xffffffff
(using the normal two's complement value of-1
). – Some programmer dude