A C language keyword worthy of shunning is union. It joins goto as another keyword to avoid, but union is more in the realm of the deprecated gets() function in that it has a potential for dangerous exploits. So why not have some fun with it before the C Lords banish it from the language?
No, I have no insight as to whether the union keyword will be banished in the next C language update. It is, however, on the list of things to avoid as it can be exploited as a weakness.
I’ve written about the union keyword before. As a summary, it’s a data container similar to a structure in its declaration. Like the structure, a union contains identifiers. But unlike a structure, the union’s identifiers share the same data space. So whereas a structure hosts multiple members of different types each with its own space, a union holds a multiple members of different types sharing a single space. It’s the single space part that’s dangerous: You can set data of one type into the union and access it via another type. Such data typing inconsistency isn’t present in modern programming languages nor is there any compiler oversight regarding how the data is interpreted.
The following code illustrates a union with two members, an integer and a character:
2026_09_19-Lesson.c
#include <stdio.h>
int main()
{
union stow {
int l;
char c;
} s;
s.l = 0x87654321;
printf("Union 's' stores: 0x%X\n",s.l);
printf("But also: %c\n",s.c);
return 0;
}
The union stow contains two members: int l and char c. Variable s is created as the union is declared.
Hex value 0x87654321 is assigned to member s.l. The first printf() statement outputs this value. The second printf() statement accesses member s.c, the character, and outputs its value. Both member use the same data stored in the union’s space to generate this output:
Union 's' stores: 0x87654321 But also: !
The storage space for union stow is large enough to contain an integer value, 32 bits. Figure 1 illustrates how this storage may look.

Both members of the union share the storage space, but access only a relevant part.
Integer s.l stores its full value in the space allocated for the union, four bytes. Character s.c uses only one of those bytes. Because the values share the same storage space, 0x21 is assigned to s.c when 0x87654321 is set for member s.l.
To confirm the union’s size, I added this line to the code:
printf("Union 's' is %lu bytes\n",sizeof(s));
Here is the updated output:
Union 's' stores: 0x87654321 But also: ! Union 's' is 4 bytes
The sizeof operator confirms that union s occupies four bytes of storage, the size of an int, its largest member.
Next week I continue my exploration of the union, with an example of unions were once an important part of C programming back in the early PC days.