In C99, you can use a designated union initializer:
union {
char birthday[9];
int age;
float weight;
} people = { .age = 14 };
In C++, unions can have constructors.
In C89, you have to do it explicitly.
typedef union {
int x;
float y;
void *z;
} thing_t;
thing_t foo;
foo.x = 2;
By the way, are you aware that in C unions, all the members share the same memory space?
int main ()
{
thing_t foo;
printf("x: %p y: %p z: %p\n",
&foo.x, &foo.y, &foo.z );
return 0;
}
output:
x: 0xbfbefebc y: 0xbfbefebc z: 0xbfbefebc