Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!unmvax!pprg.unm.edu!topgun!mustang!nntp-server.caltech.edu!seismo.gps.caltech.edu!bruce From: bruce@seismo.gps.caltech.edu (Bruce Worden) Newsgroups: comp.lang.c Subject: Re: BSD bzero() & NULL Message-ID: <1990Nov14.225031.12105@nntp-server.caltech.edu> Date: 14 Nov 90 22:50:31 GMT References: Sender: bruce@seismo.gps.caltech.edu (Bruce Worden) Organization: California Institute of Technology, CA Lines: 28 Nntp-Posting-Host: sis.gps.caltech.edu In article jl57+@andrew.cmu.edu (Jay Laefer) writes: >char *fred; >fred = 0; > [ .... ] >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 *)) >My gut reaction is no because this zeros out a block of memory and I'm >not guaranteed that the computer's internal representation of NULL is a >zero bit pattern. It won't work, but not for the reason you stated. bzero() will zero out sizeof(char *) bytes starting at the address `fred', which has not been initialized, so you will simply be zeroing out some memory at a random location. I imagine that you meant to ask whether bzero((char *)&fred, sizeof(char *)); will work, in general. And the answer is no, for the reason you stated. (There may also be an issue as to whether (char *)&fred is an acceptable argument to bzero().) BTW, memset() would probably be better in an ANSI C program, since it is defined by the standard, and bzero() is not. -------------------------------------------------------------------------- C. Bruce Worden bruce@seismo.gps.caltech.edu 252-21 Seismological Laboratory, Caltech, Pasadena, CA 91125