Frage

Recently faced with an interesting interpretation of the EOF character console windows. On some machines running windows 7 code putchar (255) && putchar (-1) is displayed as a space character, and some as 'a' character. The second confuses me. Tell me please, why is this happening?

War es hilfreich?

Lösung

EOF is not a character, it's more like a signal (not the Unix signal) indicating End-of-File. Is value is implementation dependent, but guaranteed to be unequal to any valid character, usually -1.

When you use putchar(EOF), or putchar(-1), it's converted to unsigned char, 255. But the ASCII value 255 isn't a printable character, the result varies in different machines.

Andere Tipps

The actual value of EOF is system-dependent (but is commonly -1, such as in glibc) and is unequal to any valid character code.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top