title: How to remove segmentation fault (core dumped) error while implementing strcat?
body: <p>9I am learning pointers from K&amp;R. I was trying to implement strcat (ubuntu, gcc). The code is compiling but when I run it, i get the segmentation fault error. I searched the web for it, but all i could know is that I am "trying to access a memory location that I am not supposed to or allowed to access". But, I could not find the error in the code.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void xstrcat(char *s, char *t);
  
  int main(void) {
      char *s = "hel";
      char *t = "lo.";
      xstrcat(s, t);
      printf("%s",s);
      return 0;
  }
  
  void xstrcat(char *s, char *t) {
      while(*s)
              s++;
      while(*s++ = *t++)
              ;
  }
  </code></pre>
  
  <p>Please tell me where exactly is the error and why?</p>