* Sérgio Basto:
stdio.h defines EOF as -1 , so if we want work with files
and use EOF character, we need use signed chars, though .
No, this is not how it works.
Most C interfaces (hopefully all of them, but I wouldn't be sure) that
use in-band signaling for EOF return ints. EOF is returned as int, and
the characters are returned after casting them to unsigned char, even if
char is signed on the architecture.
So getchar returns 255 when reading the character 'ÿ' in ISO-8859-1, and
-1 for EOF.
It is a common mistake to use a char variable to store the result of
getchar and similar functions because this way, you cannot tell 'ÿ' and
EOF apart. This leads either to premature detection of EOF, or infinite
loops reading 'ÿ' over and over again, depending on the architecture.
Thanks,
Florian