title: Writing to string literal through pointer vs. array
body: <p>In the chapter 5 of K&amp;R C (2nd edition), the following two statements are given and said to have a subtle difference (I am pasting the text as it is)</p>
  <blockquote>
  <p>There is an important difference between these definitions:</p>
  <pre><code>char amessage[] = &quot;now is the time&quot;; /* an array */
  
  char *pmessage = &quot;now is the time&quot;; /* a pointer */
  </code></pre>
  <p><code>amessage</code> is an array, just big enough to hold the sequence of
  characters and <code>'\0'</code> that initializes it. Individual characters within
  the array may be changed but <code>amessage</code> will always refer to the same
  storage. On the other hand, <code>pmessage</code> is a pointer, initialized to
  point to a string constant; the pointer may subsequently be modified
  to point elsewhere, but the result is undefined if you try to modify
  the string contents.</p>
  </blockquote>
  <p>I am not able to understand what they want to imply here. It says that for <code>pmessage</code>, the result is undefined if you try to modify the string constants. What is the result they are talking about, how can we modify the string constants and why will the result be undefined ?</p>
  <p>Also it says that <code>amessage</code> always points to the same storage. Is this storage the storage the array is allocated when it gets defined?</p>
  <p>Can someone please explain in a better way ? I would be very grateful !!</p>