Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!ucdavis!austin From: austin@scallion.ucdavis.edu (Darren Austin) Newsgroups: comp.lang.c Subject: Union initialization Message-ID: Date: 29 May 89 23:05:30 GMT Sender: uucp@ucdavis.ucdavis.edu Reply-To: austin@clover.ucdavis.edu Followup-To: alt.dev.null Distribution: comp Organization: UC Davis Division of Computer Science Lines: 32 Hello, I have an application that uses unions for one of the major data structures. I would like to be able to initialize one of these unions similar to the way that you can with arrays and structures, for example: struct foo { int a; char b[10]; }; struct foo f = { 4, "hello" }; is allowed, but when I tried a similar method to initialize a union, the compiler complained. Is there a way to initialize static unions in C? A quick glance at K&R didn't yield any information on the subject. I assume that means that it is not possible. If it isn't, are there ways around this problem, or am I just missing something very basic? Any help would be most appreciated, but please SEND RESPONSES TO ME THROUGH E-MAIL. I do not want to start another silly/stupid question flame fest. Thanks, --Darren -- --------------------------------------+------------------------------- Darren Austin | Is is a mistake to think you UC Davis Division of Computer Science | can solve any major problem austin@clover.ucdavis.edu | just with potatoes. --------------------------------------+-------------------------------