Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!elroy!cit-vax!tybalt.caltech.edu!yair From: yair@tybalt.caltech.edu (Yair Zadik) Newsgroups: comp.lang.c Subject: Re: C union problems (or is a pointer a pointer?) Message-ID: <10537@cit-vax.Caltech.Edu> Date: 29 Apr 89 09:36:52 GMT References: <15058@sequent.UUCP> <1989Apr26.215903.10906@utzoo.uucp> Sender: news@cit-vax.Caltech.Edu Reply-To: yair@tybalt.caltech.edu.UUCP (Yair Zadik) Organization: California Institute of Technology Lines: 25 I like the C++ solution the best: you can declare a union without a name as long as it is within a struct. These 'anonymous' unions behave they way you would expect them to. You could just declare: typedef struct { int a; char b; union { int *c1; char *c2; } } randomtype; randomtype random; Then you could refer to random.a, random.b, random.c1, and random.c2 just like in a Pascal record variant. The only problem is that you need a C++ compiler to handle it. yair@tybalt.caltech.edu