title: Union value in C
body: <p>Can somebody explain to me what happens with br agument in union, after assigning str.a and str.b? We need to set that value before calling the function above? I tried to run the code in simulator <a href="https://pythontutor.com/render.html#mode=display" rel="nofollow noreferrer">https://pythontutor.com/render.html#mode=display</a> which says that the value of br is 516 before calling the function. How is that possible?</p>
  <pre><code> #include &lt;stdio.h&gt;
  void f(short num, short* res){
   if (num){
   *res = *res * 10 + num%10;
   f(num / 10, res);
  }}
  
  
  typedef union {
   short br;
   struct {
   char a, b;
   } str;
  } un;
  
  void main() {
   short res = 0; un x;
   x.str.a = 4; x.str.b = 2;
   f(x.br, &amp;res); x.br = res;
   printf(&quot;%d %d %d\n&quot;, x.br, x.str.a, x.str.b);}
  </code></pre>