title: Storage, semantics, and string literals in C confusion
body: <p>I've been reading C programming Second edition by B &amp; K.
  In the Appendix A of the book, where they define the standard reference for C, they say:</p>
  <p>&quot;A string literal, also called a string constant, is a sequence of characters surrounded by double quotes as in &quot;...&quot;. A string has type ``array of characters'' <strong>and storage class static</strong> and is initialized with the given characters.&quot;</p>
  <p>This means that any sequence of characters between double quotes have static storage.</p>
  <p>Now, in another part of the book, they say:</p>
  <p>&quot;Character arrays are a special case of initialization; a
  string may be used instead of the braces and commas notation:
  <code>char pattern[] = &quot;ould&quot;;</code> is a shorthand for the longer but equivalent
  <code>char pattern[] = { 'o', 'u', 'l', 'd', '\0' };</code>
  In this case, the array size is five (four characters plus the terminating '\0').&quot;</p>
  <p>In the shorthand statement, does the string &quot;ould&quot; have static storage or not? Or is it <em>just</em> an array of characters as they make it out to be.</p>
  <p>Some place later in the book, they also say that:</p>
  <p>&quot;There is an important difference between these definitions:
  <code>char amessage[] = &quot;now is the time&quot;; /* an array */</code> and
  <code>char *pmessage = &quot;now is the time&quot;; /* a pointer */</code>
  amessage is an array, just big enough to hold the sequence of characters and '\0' that initializes
  it. Individual characters within the array may be changed but amessage will always refer to the
  same storage. On the other hand, pmessage 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.&quot;</p>
  <p>So, correct me if I am wrong, what I am basically getting from all of this is that:
  Once a sequence of characters enclosed in double quotes appear in a program, they stay in memory and aren't destroyed till the end of the program. And also, they are stored in memory as an array of characters, as in <code>char pattern[] = { 'o', 'u', 'l', 'd', '\0' }</code>. And, when a string appears on the right side of an <em>initialization</em>, like in <code>char pattern[] = &quot;ould&quot;;</code>, the string is copied into the array, character by character into the array's indices, and stays in memory until the end of program as a sequence of characters too regardless of whether pattern[] is destroyed or not.</p>
  <p>I am sorry if this is a bit long but it's kinda been confusing me, I've read other answers on this topic on here too but they don't seem to connect well.</p>