Re: quick question.

From: Andrew M. Hoerter (
Date: 07/30/95

Pink Floyd writes:

>   if (GET_ROOM_SPEC(ch->in_room) != NULL)
> couldn't the same thing be accomplished with this? :
>   if (GET_ROOM_SPEC(ch->in_room))

	Yes. They are functionally equivalent. The compiler converts the
second form into the first anyway, such that `if (a)' becomes `if (a != 0)'.
0 then becomes the proper type of null pointer. (this is in the comp.lang.c

> I've noticed statements like the first one in lots of places in the circle
> code.   Wouldn't the program be slightly smaller with the second statment?

	Nope, at least not to my knowledge. It would be converted right back
as described above. Which form you use is basically a matter of style, or
which you think is more readable. Personally, I prefer `if (pointer)'.


This archive was generated by hypermail 2b30 : 12/07/00 PST