Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!dayton!viper!john From: john@viper.UUCP (John Stanley) Newsgroups: comp.lang.c Subject: Re: union initialization Message-ID: <938@viper.UUCP> Date: Wed, 6-May-87 17:29:32 EDT Article-I.D.: viper.938 Posted: Wed May 6 17:29:32 1987 Date-Received: Sat, 9-May-87 01:33:48 EDT References: <3290@burdvax.PRC.Unisys.COM> <1722@plus5.UUCP> <455@haddock.UUCP> <6483@mimsy.UUCP> <7023@bu-cs.BU.EDU> Reply-To: john@viper.UUCP (John Stanley) Organization: DynaSoft Systems Lines: 38 In article <7023@bu-cs.BU.EDU> bzs@bu-cs.BU.EDU (Barry Shein) writes: > >My relatively worthless 2c: > >union foo { > int a; > char *p; > double foo; >} u[] = { > {0,,}, /* init the int */ > {,NULL,}, /* init the char * > {,,0} /* init the double */ >}; > How about the following? (after I change 2nd foo to baz to avoid confusion): union foo { int a; char *p; double baz; } fu[4] = { { 0}, /* Defaults to init the 1st element (int) ((ANSI)) */ {a: 0}, /* init the int */ {p: NULL}, /* init the char pointer */ {baz: 0.0} /* init the double */ }; I don't know about you, but this looks very readable to me.... --- John Stanley (john@viper.UUCP) Software Consultant - DynaSoft Systems UUCP: ...{amdahl,ihnp4,rutgers}!{meccts,dayton}!viper!john