title: Structure within union in C
body: <p>When a variable is associated with a union, the  compiler allocates the  memory by considering the size of the largest memory. So, size of union is equal to the size of largest member. so it means Altering the value of any of the member will alter other member values.
  but when I am executing the following code, </p>
  
  <pre><code>output: 4 5 7.000000
  union job
  {
      int a;
      struct data
      {
          double b;
          int x
      }q;
  } w;
  
  
  w.q.b=7;
  w.a=4;
  w.q.x=5;
  
  printf("%d %d %f",w.a,w.q.x,w.q.b);
  return 0;
  }
  </code></pre>
  
  <p>Issue is that, first I assign the value of a and later modified the value of q.x, then the value of a would be overridden by q.x. But in the output it still shows the original value of a as well as of q.x. I am not able to understand why it is happening?</p>