title: Segmentation fault(core dumped) - cPointers [C]
body: <p>I was assigned with a task of completing an assignment in C, without being taught C. (I have been learning Java) I am not sure how to fix this error nor do I know what the error means.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  //int mystrcmp(char * s, char * t);
  
  int  main(int argc, char * argv[])
  {
  
  // #1 Prints out cmd line arguments
  
  int i;
  for (i = 0; i &lt; argc; ++i)
  {
  
      printf("%s\n",argv[i]);
  
  }
  
  printf("\n"); //Spaceholder
  
  // #2  String Compare
  printf("%s %s\n", argv[1], argv[2]);
  printf("Returned Value: %d\n", mystrcmp(argv[1], argv[2]));
  //mystrcmp(argv[1],argv[2]);
  
  
  // #3 String Concatenate
  
  printf("\n"); //Spaceholder
  printf("String Concatenate: %s\n", mystrcat(argv[1]));
  
  // #4 String Copy
  
  printf("\n"); //Spaceholder
  //  printf("String Copy: %s\n" , mystrcpy(argv[1]));
  
  }
                       ///////////
                      //Methods//
                     ///////////
  
  /* srtcmp: return &lt; 0 if s &lt; t, 0 if s==t, &gt; 0 if s &gt; t */
  
  int mystrcmp(char * s, char * t)
  {
  
  int i;
  for(i = 0; s[i] &amp;&amp; s[2]; ++i)
  {
      if (s[i] == t[i] || (s[i]) == t[i])
         continue;
      else
         break;
  }
  
  if (s[i] == t[i])
      return 0;
  if ((s[i]) &lt; (t[i])) 
      return -1;
          return 1;
  
  }
   mystrcat(char *dest, char *source)
  {
      int a = 0;
  
      while(*(dest + a) != '\0')
      {
              a++;
      }
  
      int b = 0;
  
      while(*(source + a) != '\0')
      {
               *(dest + a) = *(source + b);
               a++;
               b++;
      }
  
  }  
  
   mystrcpy(char * s, char * dest)
   {
     while((*s++ = *dest++)!= '\0')
      ; 
     return *dest;
   }
  </code></pre>
  
  <p>I am assuming the error is coming from my mystrcat.</p>