Creating pointer with all bits 0 (was: Referencing NULL pointers)

Conor P. Cahill cpcahil at virtech.UUCP
Fri Sep 1 02:49:58 AEST 1989


In article <1989Aug31.052756.18524 at sq.sq.com>, msb at sq.sq.com (Mark Brader) writes:
> 
>       int *p;
>       memset ((void *) p, 0, sizeof p);

This would probably drop core on most systems.  You probably want to 
do something like:

       memset ((void *) &p, 0, sizeof p);
                        ^^

> Or bzero() if you have that and not memset(), or for that matter
> there's the trickier but more universally available way:
> 
>       strncpy ((char *) p, "", sizeof p);

Yet again, you need the & on the p.



-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list