title: Memory fault and pointer to string
body: <p>So I'm trying to reverse a string, but I get a memory fault. Memory for s and s1 is initialized enough to accomodate the '/0' character as well.</p>
  
  <p>Interestingly if I remove *s=*s1 and print s1 instead the program works.
  But I haven't even set the "\0" character at the end of s1 so how does it even know where to stop printing?</p>
  
  <p>And in the case below what exactly is the issue?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  void main(void)
  {
      char *s = "abcdefghijklmnop", *s1=malloc(17);
      int i;  
      for(i=0;i&lt;strlen(s);i++)
      {
          *(s1+i) = *(s+strlen(s)-1-i);
      }
      *s=*s1;
      printf("%s",s);
  }
  </code></pre>