Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!hubcap!ncrcae!ncrlnk!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: malloced structure initilization Message-ID: <1045@auspex.UUCP> Date: 18 Feb 89 10:07:05 GMT References: <202@sabin.UUCP> <8894@alice.UUCP> <1874@dataio.Data-IO.COM> <9649@smoke.BRL.MIL> <2363@iscuva.ISCS.COM> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 39 >Does this mean that if I write: > > #include > > static struct { > float ward; > int june; > char wally; > long beaver; > double eddie; > } mayfield; > >I'm GUARANTEED (at least by the ANSI standard) to get (something like): > > 0.0, 0, , 0, 0.0 > >even on "unusual" architectures where zero-bit-pattern != 0? Yes (if means '\0'). >Presumably that means that any pointers I mention in the structure are >also set to proper nil pointers of appropriate type? Yes. >Specifically, does the initialization of static variables to "zero of the >appropriate type" apply to members of static structures? Yes. From the May 13, 1988 dpANS: 3.5.7 Initialization ... If an object that has static storage duration is not initialized explicitly, it is initialized implicitly as if every member that has arithmetic type were assigned 0 and every member that has pointer type were assigned a null pointer constant.