title: Copying structure in C with assignment instead of memcpy()
body: <p>Up until recently, I have only seen copying of structure fields done with <code>memcpy()</code>. In classes and online instructions, copying the contents of one struct into another generally looks like</p>
  
  <pre><code>struct block *b0 = malloc(sizeof(struct block));
  struct block *b1 = malloc(sizeof(struct block));
  /* populate fields in *b0 */
  memcpy(b1, b0, sizeof *b1); /* copy contents of b0 into b1 */
  /* free b0, b1 */
  </code></pre>
  
  <p>However, this task can also be accomplished by a simple assignment replacing the <code>memcpy()</code>.</p>
  
  <pre><code>*b1 = *b0; /* dereferenced struct assignment */
  </code></pre>
  
  <p>Is there good reason why this isn't as widely used (at least in my limited experience)? Are these two methods—assignment and <code>memcpy()</code>—equivalent, or is there some compelling reason to use <code>memcpy()</code> in general?</p>