title: While loop assignment (pointers)
body: <p>In the K&amp;R C Programming book, I came across this code snippet for string copying:</p>
  
  <pre><code>/* strcpy: copy t to s; pointer version 3 */
  void strcpy(char *s, char *t)
  {
  while (*s++ = *t++)
  ;
  }
  </code></pre>
  
  <p>This correctly copies two character arrays (of course it does).
  My question is, why does it work the way it does? There doesn't seem to be any condition checking inside the while. There is an assignment and a post increment. My gut feeling is that this always evaluates to true (similar to how while(1) always evaluates to true, and we need a break somewhere to get out of the loop.</p>
  
  <p>There is nothing <em>inside</em> of the loop either. No bound checking, no ifs, nothing. It all seems very risky and reckless to me. Can someone walk me through this? Thanks.</p>