title: C programming strcat using pointer
body: <p>I am a beginner in C. I wanted to make strcat function using pointers. I made it but don't know what is wrong with it. I used gcc compiler and it gave segmentation fault output.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  char scat(char *,char *);
  
  void main()
  {
      char *s="james";
      char *t="bond";
  
      char *q=scat(s,t);
      while(*q!='\0') printf("the concatenated string is %c",*q);
  }
  
  char *scat(char *s,char *t)
  {
      char *p=s; 
      while(*p!='\0'){
          p++;
      } 
      while(*t!='\0'){
          *p=*t;
          p++;
          t++;
      }
      return p-s-t;
  }
  </code></pre>