/** * A simple example of a union and the space savings therein * **/ #include /** * A union. * If this were a struct, it would use 4 + 8 + 24 bytes * As a union, it uses the number of bytes of its largest contents * of 24 bytes * **/ typedef union { int uA; long uB; char aa[24]; } aUnion; int main(int argc, char const *argv[]) { // put 4 instance of the untion into an array so // can see the starting point of each item in memory aUnion a[4]; for (int i = 0; i < 4; i++) printf("%d %ld\n", i, &a[i]); return 0; }