TO C OR NOT TO *C

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Oct 19 19:53:01 AEST 1989


In article <8864 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:
>The reason this works is that on the Sun, chars are signed, printable
>characters have positive values, and EOF is negative. But you still
>should use int, if only to be morally correct.

It's not a matter of "morality", it's a matter of practicality.
Relying on an implementation quirk will get you into trouble when:
	- the implementation changes
	- the compiler is invoked with a switch that treats "char"
		as unsigned
	- the code is ported to a different implementation
It's especially foolish when it is just as easy to write the code
correctly as to write it in an implementation-dependent way.



More information about the Comp.lang.c mailing list