"union" Data Type

Q

What's the output of the following program? And why?

#include 
main() {
  typedef union {
    int a;
    char b[10];
    float c;
  }
  Union;
  
  Union x,y = {100};
  x.a = 50;
  strcpy(x.b,"hello");
  x.c = 21.50;
  printf("Union x : %d %s %f n",x.a,x.b,x.c);
  printf("Union y : %d %s %f n",y.a,y.b,y.c);
}

✍: Guest

A
(This question has not been answered yet. If you know the answer, please share it in a comment below.)

2007-02-26, 6680👍, 0💬