Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: BSD bzero() & NULL Message-ID: <14464@smoke.brl.mil> Date: 15 Nov 90 18:27:51 GMT References: Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 21 In article jl57+@andrew.cmu.edu (Jay Laefer) writes: >I realize that the following assignments are equal: >char *fred; >fred = 0; >fred = (char *)NULL; >because the compiler is responsible for translating the zero bit pattern >into its internal representation of NULL. They are both valid ways to assign a null pointer value to "fred", but NOT bacuse of anthing to do with all-zero bit patterns. In fact both 0 and NULL is such contexts stand in for a null pointer constant, which need not have an all-zero bit representation. That's right -- the "0" in the above code is NOT an integer, even though it "looks" like one. >But, given that bzero() directly fills an area with zeros, can I assume >that the following is equivalent to the above? >bzero(fred, sizeof (char *)) No, indeed this would try to fill "fred" with zero bits, which may not be the right way to represent a null pointer (it depends on the implementation).