title: How does this string initilization work in C?
body: <p>Whilst browsing through some code on a programming forum i found this:</p>
  <pre><code>char *s = &quot;ab&quot; &quot; cd&quot; &quot; ef&quot;;
  
  printf(&quot;%s&quot;, s);
  </code></pre>
  <p>I would consider myself okay at C (sometimes) so after seeing i was very surprised, i had to test it and compile it for myself. And to my surprise it compiled with no errors!</p>
  <p>Output:</p>
  <pre><code>ab cd ef
  </code></pre>
  <p>How on earth does this even work? I never even knew something like this was possible in C and am pretty surprised.</p>
  <p>Normally when declaring a string:</p>
  <pre><code>char *s &quot;hello&quot;;
  </code></pre>
  <p>The string literal &quot;hello&quot; decays to a pointer to the first element of the character array that makes up &quot;hello&quot;, so <code>s</code> ends up pointing to <code>'h'</code>.</p>
  <p>However i could not use the same logic in the strange code sample i found. If i had to guess i would assume each string literal (<code>&quot;ab&quot;</code>,<code>&quot; cd&quot;</code>, <code>&quot; ef&quot;</code>) is not actually a separate string instead it is interpreted as one whole string.</p>
  <p>But this is just a guess. Could someone please explain how and why this works?</p>