From: Eric Amick Subject: Re: How do I initialize a union? Newsgroups: comp.os.msdos.djgpp,comp.lang.c References: <7secmg$8nd$1 AT solomon DOT cs DOT rose-hulman DOT edu> Organization: the end of my rope User-Agent: tin/pre-1.4-980105 (UNIX) (SunOS/5.6 (sun4u)) Lines: 25 Message-ID: Date: Fri, 24 Sep 1999 02:27:25 GMT NNTP-Posting-Host: 168.143.0.8 X-Complaints-To: abuse AT verio DOT net X-Trace: iad-read.news.verio.net 938140045 168.143.0.8 (Fri, 24 Sep 1999 02:27:25 GMT) NNTP-Posting-Date: Fri, 24 Sep 1999 02:27:25 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In comp.lang.c Damian Yerrick wrote: > typedef union Foo > { > void *data; > Boxers trunks; > } Foo; > Foo bar; > How do I set up a declaration that defines an initial value for > bar.data or bar.trunks? If you mean an actual initializer, it has to be for the first element declared in the union: Foo bar = {NULL}; If you want to set data sometimes and trunks other times, you'll have to use an assignment. -- Eric Amick Columbia, MD eamick AT clark DOT net