Path: utzoo!mnetor!uunet!husc6!mailrus!nrl-cmf!cmcl2!brl-adm!adm!dsill@NSWC-OAS.arpa From: dsill@NSWC-OAS.arpa (Dave Sill) Newsgroups: comp.lang.c Subject: Re: Why NULL is 0 Message-ID: <12466@brl-adm.ARPA> Date: 17 Mar 88 15:07:20 GMT Sender: news@brl-adm.ARPA Lines: 40 I wrote: >In article <800@zippy.eecs.umich.edu> Jan Wolter writes: >> char *p2 = zero; /* is this a null pointer? */ > >Maybe. K&R say assignments between pointers and ints are nonportable, >as are assignments between different types of pointers. > >> char *p3 = (char *)zero; /* what's this? */ > >Exactly the same as p2. K&R define a cast as performing the >conversions required to assign the operand to a variable of the type >of the cast. K&R page 42: "... (type-name) expression ... The precise meaning of a cast is in fact as if *expression* were assigned to a variable of the specified type..." This leads one to the conclusion that char *p = zero; and char *p = (char *)zero; give the same result. Why, then, does the former cause a warning about an illegal combination of pointer and integer? Is the sole function of the cast in the latter to prevent such a warning? >>(Frankly, >>the more I read on this subject, the more I think K&R didn't have their minds >>entirely clear on this business either.) > >Maybe you should read some more. I'd suggest reading the dpANS-C, where this is all much more well-defined. ========= The opinions expressed above are mine. "Meanings receive their dignity from words instead of giving it to them." -- Blaise Pascal