Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: pointers, tests, casts Message-ID: <494@auspex.UUCP> Date: 23 Nov 88 17:50:42 GMT References: <11130@dartvax.Dartmouth.EDU> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 18 >In assignments, a 0 or NULL is cast implicitly to the correct pointer >type (I think, please correct me if I'm wrong). This is correct. >What about the '==' comparison above? Would "(ptr == 0)" get evaluated >correctly? In any valid C implementation, it will be. The compiler certainly knows enough to do the implicit conversion, just as it does in the case of an assignment. >Or to push it a bit further, what about the VAX-ish standard (like >*(char *)0 = 0 ;-) "(!ptr)"? I realize that it is probably better to >explicitly cast & compare, but it did kind of make sense to say "if >(!ptr)..." This will also work in any valid C implementation.