title: char *str; str="HELLO"; How does that work without allocating any memory for the string?
body: <p>Code:</p>
  <pre><code>    #include &lt;stdio.h&gt;
      int main() {
          char *str;
          char i = 'a';
          str = &amp;i;
          str = &quot;Hello&quot;;
          printf(&quot;%s, %c, %x, %x&quot;, str, i, str, &amp;i);
          return 0;
      }
  </code></pre>
  <p>I get this output:</p>
  <pre><code>Hello, a, 403064, 28ff0b
  </code></pre>
  <p>I have following two doubts:</p>
  <ol>
  <li><p>How can I store a string without allocating any memory for it. <code>str</code> is a character pointer and is pointing to where char variable <code>i</code>. When I add <code>str = &quot;Hello&quot;;</code> aren't I using <code>5</code> bytes from that location <code>4</code> of which are not allocated?</p>
  </li>
  <li><p>Since, I code <code>str = &amp;i;</code> shouldn't <code>str</code> and <code>&amp;i</code> have same value when I printf them? When I remove the <code>str = &quot;Hello&quot;;</code> statement <code>str</code> and <code>&amp;i</code> are same. And if <code>str</code> and <code>&amp;i</code> are same then I believe when I say <code>str = &quot;Hello&quot;</code> it should overwrite <code>'a'</code> with <code>'H'</code> and the rest <code>'ello\0'</code> come into the subsequent bytes.</p>
  <p>I believe the whole problem is with <code>str = &quot;Hello&quot;</code> statement. It doesn't seem to be working like what I think.</p>
  </li>
  </ol>
  <p>Please someone explain how it works??</p>