title: string concatenation without using the library function in c?
body: <p>I am writing code to emulate the strcat function in the c library and I can't pass my first test in main. I was wondering if someone could guide me as to why. here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  char *strcat(char string1[ ], char string2[ ])
  {
      int i;
      int j;
  
  
      for(i = 0; string1[i] != '\0'; i++);
  
      for(j=0;string2[j] != '\0';j++)
      {
  
          string1[i] = string2[j];
          i++;
  
  
      }
  
      string1[i] = '\0';
  }
  
  
  
  int main() { 
      char str1[81], str2[81]; 
      char again = 'y', newline; 
      while (again == 'y') { 
          printf("Enter a string\n"); 
          scanf("%s", str1); 
          printf("Enter another string\n"); 
          scanf("%s", str2); 
          printf("The concatention is %s\n", strcat(str1, str2)); 
          printf("Second test:  The concatenation is %s\n", str1);
          printf("The second string is still %s\n", str2); 
          printf("Again? (y/n)\n"); 
          scanf("%c%c", &amp;newline, &amp;again); 
      }
  }
  </code></pre>