title: printf value in union depending on format
body: <p>It is possible to <code>scanf</code> values into a union depending on the format specifier.</p>
  
  <pre><code>union {
      int i;
      double f;
  } u;
  
  scanf("%lf", &amp;u.i); // implicitly scan the double
  
  printf("%lf", u.f); // explicitly print the double
  </code></pre>
  
  <p>This works because <a href="http://en.cppreference.com/w/c/io/fscanf" rel="nofollow"><code>scanf</code></a> takes pointers as arguments, and all elements in the union are aligned, <code>(void*)&amp;u.i == (void*)&amp;u.f</code>.</p>
  
  <p>Is it possible to change the <a href="http://en.cppreference.com/w/c/io/fprintf" rel="nofollow"><code>printf</code></a> line in a way that does the same thing, picking the correct value to print from the union based on the format, without accidentally slicing some of the possible values?</p>
  
  <pre><code>printf("%lf", ???); // implicitly print the double
  </code></pre>