title: Accessing struct member by address
body: <p>Consider a struct with two members of integer type. I want to get both members by address. I can successfully get the first, but I'm getting wrong value with the second. I believe that is garbage value. Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  typedef struct { int a; int b; } foo_t;
  
  int main(int argc, char **argv)
  {
  
    foo_t f;
    f.a = 2;
    f.b = 4;
    int a = ((int)(*(int*) &amp;f));
    int b = ((int)(*(((int*)(&amp;f + sizeof(int)))))); 
    printf("%d ..%d\n", a, b);
    return 0;
  }
  </code></pre>
  
  <p>I'm getting: </p>
  
  <blockquote>
    <p>2 ..1</p>
  </blockquote>
  
  <p>Can someone explain where I've gone wrong?</p>