Topic : C-Language Documentation Author : John Kormylo Version : C.HYP 1.0 Subject : Documentation/C-Language Nodes : 233 Index Size : 6362 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : en @default : @help : Help @options : +g -i -s +x +z -t4 @width : 75 View Ref-File[ Unions ] A union is a set of data items of different types with the same address in memory. For example, union pack { unsigned long l; unsigned char bytes[4]; } u; u.bytes[0] = 'p'; u.bytes[1] = 'a'; u.bytes[2] = 'c'; u.bytes[3] = 'k'; accomplishes the same thing as u.l = (((((((long) 'p') << 8) | 'a') << 8) | 'c') << 8) | 'k': When you initialize a union, it uses the type of the first entry. See also Names, Data Types and typedef.