Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!rochester!rutgers!apple!voder!kontron!optilink!cramer From: cramer@optilink.UUCP (Clayton Cramer) Newsgroups: comp.lang.c Subject: Re: Unions Keywords: What can they be used for? Message-ID: <580@optilink.UUCP> Date: 20 Oct 88 17:35:43 GMT References: <322@hrc.UUCP> Organization: Optilink Corporation, Petaluma, CA Lines: 29 In article <322@hrc.UUCP>, dan@hrc.UUCP (Dan Troxel VP) writes: > > Except for the memory savings, what are Unions suited for? > -- > Dan Troxel VP of Computer Operations @ They can be useful for showing that several different possible alternatives are just that -- alternatives. Consider: union uTag { int CmdTblJumpIndex; PFI FuncToExecute; char* SystemCmdToRun; } ActionToTake; vs. int CmdTblJumpIndex; PFI FuncToExecute; char* SystemCmdToRun; The first example shows that all three are alternatives, and in fact, if you tried to write code that used two of them at once, it wouldn't work correctly. -- Clayton E. Cramer ..!ames!pyramid!kontron!optilin!cramer