title: C pointers - Reading values from absolute addresses vs AddressOf operator (&)
body: <p>If I did not compile the code I'd say that <strong>1</strong> and <strong>2</strong> give the same result as both of them have an <em>int</em> pointer <em>p</em> pointing to variable <em>age</em>. Dereferencing <em>age</em> in both <strong>1</strong> and <strong>2</strong> should give the same result. I also understand that <strong>3</strong> will just give me the first byte of variable <em>age</em> as it's of type <em>char</em>. I can't explain why <strong>1</strong> and <strong>2</strong> give different results and why <strong>2</strong> and <strong>3</strong> give the same result. </p>
  
  <p><strong>1</strong></p>
  
  <pre><code>int age = 20;
  int* p = (int *)0x66FC9C;
  printf("You're : %d\n", *p );
  </code></pre>
  
  <p><strong>2</strong></p>
  
  <pre><code>int age = 20;
  int *p = &amp;age;
  printf("You're : %d\n", *p );
  </code></pre>
  
  <p><strong>3</strong></p>
  
  <pre><code>int age = 20;
  char* p = (char *)0x66FC9C;
  printf("You're %d\n", *p );
  </code></pre>
  
  <hr>
  
  <p><em>Follow-up</em></p>
  
  <p>It's weird because when I do :</p>
  
  <pre><code>int age1 = 20;
  int age2 = 19;
  int* p = &amp;age2;
  printf("You're %d  %d  %d  %d\n", *p, *(p+1), &amp;age1, &amp;age2 );
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IZmtW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IZmtW.png" alt="enter image description here"></a></p>
  
  <p>and I actually <em>print</em> the addresses I always get the <em>p+1</em> right (meaning I can predict the address) but if I do :</p>
  
  <pre><code>int age1 = 20;
  int age2 = 19;
  int* p = &amp;age2;
  printf("You're %d  %d\n", *p, *(p+1)  );
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/cHbAN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cHbAN.png" alt="enter image description here"></a></p>
  
  <p>I can never guess it. It's like C knows is being watched... <em>cough cough double slit experiment</em></p>