TRUE and FALSE (was: NULL as a string terminator)

Andrew Koenig ark at alice.UUCP
Tue Aug 21 09:02:46 AEST 1990


In article <12249 at netcom.UUCP>, ergo at netcom.UUCP (Isaac Rabinovitch) writes:

> On the other hand, you can say (and I used to) that using 1 and
> 0 instead of TRUE and FALSE is a similar "familiar practice", since any
> competant C programmer knows that C booleans are just integers.  
> In this case it probably makes a big difference that TRUE and FALSE are
> ordinary English words, not obscure acronyms.

Unfortunately, using TRUE and FALSE opens a great gaping hole:
one would expect that

	x == TRUE

would mean the same as

	x != FALSE

but of course it doesn't -- at least not if you use the usual C
convention that 0 is false and any other value is true.

> I recently came up against a similar clash of "familiar concepts" in
> C.  People were arguing (was it in this group?) over why programmers
> use "i" instead of "i == 0".

Well, for one thing,

	if (i) foo();

and

	if (i == 0) foo();

mean precisely the opposite of each other.  :-)
-- 
				--Andrew Koenig
				  ark at europa.att.com



More information about the Comp.lang.c mailing list