A union is a special data type that enables us to store different data types in a single definition, similar to the structure; however, only one of the members may contain data at any one time. The following shows the syntax for defining a union:
union name {
  variable list
  .
  .
};
If the syntax looks a lot like the syntax for a structure. In fact, it is the same syntax except for the struct/union keywords.
Let's see how we would use a union. The following code defines a new union:
union some_data {
  int i;
  double d;
  char s[20];
};
The preceding code defines a union named some_data that can contain an integer, double or a character string. The keyword in that last sentence is the or. Unlike the structure, which can store several different values, a union can only store one value at a time. The following code will illustrate this:
union some_data {
  int i...