title: Why casting unsigned to signed directly in C gives correct result?
body: <p>In C, signed integer and unsigned integer are stored differently in memory. C also convert signed integer and unsigned integer implicitly when the types are clear at runtime. However, when I try the following snippet,</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {    
      unsigned int a = 5;
      signed int b = a;
      signed int c = *(unsigned int*)&amp;a;
      signed int d = *(signed int*)&amp;a;
  
      printf("%u\n", a);
      printf("%i\n", b);
      printf("%i\n", c);
      printf("%i\n", d);
  
      return 0;
  }
  </code></pre>
  
  <p>with the expected output of:</p>
  
  <pre><code>5
  5                   //Implicit conversion occurs
  5                   //Implicit conversion occurs, because it knows that *(unsigned int*)&amp;a is an unsigned int
  [some crazy number] //a is casted directly to signed int without conversion
  </code></pre>
  
  <p>However, in reality, it outputs</p>
  
  <pre><code>5
  5
  5
  5
  </code></pre>
  
  <p>Why?</p>