title: strncat implementation?
body: <p>I'm sorry if this is too entry-level, but I tried implementing the library function of <strike>strcpy</strike><code>strncat()</code> as follows:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void strncat (char *s, char *t, int n) {
  // malloc to extend size of s
  s = (char*)malloc (strlen(t) + 1);
  
  // add t to the end of s for at most n characters
  while (*s != '\0') // move pointer
      s++;
  
  int count = 0;
  
  while (++count &lt;= n)
      *s++ = *t++;
  
  *(++s) = '\0';
  }
  
  int main () {
  char *t = " Bluish";
  char *s = "Red and";
  
  // before concat
  printf ("Before concat: %s\n", s);
  
  strncat(s, t, 4);
  
  // after concat
  printf ("After concat: %s\n", s);
  
  return 0;
  }
  </code></pre>
  
  <p>It compiles and runs fine...just that it doesn't concatenate at all!</p>
  
  <p>Greatly appreciate any feedback...thanks!</p>