// union_test.c - example for the use of unions

#include <stdio.h>

union _Numbers_
{
  int int_val;
  float float_val;
  double dbl_val;
};

typedef union _Numbers_ Numbers;

int main(int argc,char *argv[])
{
  Numbers test_union;

  test_union.int_val = 17;
  printf("Union holding an int, correctly interpreted: %d\n",
         test_union.int_val);
  printf("Union holding an int, wrongly interpreted!!!: %f\n",
         test_union.float_val);
  test_union.dbl_val = 26.8;
  printf("Union holding a double, correctly interpreted: %f\n",
         test_union.dbl_val);
  printf("Union holding a double, wrongly interpreted!!!: %d\n",
         test_union.int_val);
  return(0);
}
