Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: malloced structure initilization Message-ID: <1989Feb10.034819.26032@utzoo.uucp> Organization: U of Toronto Zoology References: <202@sabin.UUCP> Date: Fri, 10 Feb 89 03:48:19 GMT In article <202@sabin.UUCP> bjm@sabin.UUCP (Brendan J. McMahon) writes: >How do you initialize memory malloced for a structure without using calloc, >and without initilizing each structure element explicitly? You can try using bcopy() or memset() (Berklix and SysV respectively), but beware that things like pointers and floating-point numbers are *not* guaranteed to be initialized to anything sensible that way. The only way to reliably initialize such things to specific values (like, say, NULL or 0.0) is to do member-by-member initialization. The bit patterns for NULL and 0.0 are not guaranteed to be all zeros. -- The Earth is our mother; | Henry Spencer at U of Toronto Zoology our nine months are up. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu