title: Understanding char *, char[] and strcpy()
body: <p>My understanding is as follows:</p>
  
  <ul>
  <li><p><code>char *</code> points to a string constant, modifying the data it points to is undefined. You can, however, change where it points to.</p></li>
  <li><p><code>char[]</code> refers to a block of memory that you can change.  You can change its contents but not what it refers to.</p></li>
  <li><p><code>strcpy(dest, src)</code> copies <code>src</code> into <code>dest</code>. </p></li>
  </ul>
  
  <p>My question is, is it incorrect to use <code>strcpy()</code> with the <code>dest</code> being a <code>char *</code> <strong>that is already pointing to something</strong> (as I believe the old contents will be overwritten by <code>strcpy()</code> - which is undefined behaviour)?</p>
  
  <p>For example:</p>
  
  <pre><code>char *dest = malloc(5);
  dest = "FIVE";
  
  char *src = malloc(5);
  src = "NEW!";
  
  strcpy(dest, src); /* Invalid because chars at dest are getting overwritten? */
  </code></pre>