title: C struct pointer iteration
body: <p>I did not expect to be able to increment a pointer to a struct in a memory block of structs.  But it seems to work.  Is there any case where this does not work?  If I create a "list" of structs then I should always be able to increment the pointer to them and C will figure out how many bytes to move by?</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  struct User {
      int id;
      char name[32];
      float net_worth;
  };
  typedef struct User User;
  
  
  int main(int argc, char** argv) {
      User* u1 = (User*)malloc(sizeof(User));
      u1-&gt;id = 1;
      strcpy(u1-&gt;name, "Mike");
      u1-&gt;net_worth = 43.45;
      User* u2 = (User*)malloc(sizeof(User));
      u2-&gt;id = 2;
      strcpy(u2-&gt;name, "Pablo");
      u2-&gt;net_worth = -2.00;
      User* u3 = (User*)malloc(sizeof(User));
      u3-&gt;id = 3;
      strcpy(u3-&gt;name, "Frederick");
      u3-&gt;net_worth = 7329213.45;
  
      User** users = (User**)malloc(sizeof(User)*10);
      *users = u1;
      printf("%s\n", ((User*)(*users))-&gt;name);
      *users++;
      *users = u2;
      printf("%s\n", ((User*)(*users))-&gt;name);
      *users++;
      *users = u3;
      printf("%s\n", ((User*)(*users))-&gt;name);
  
  
      return 0;
  
  }
  </code></pre>