home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume5 / smallc / part3 / lib / strncat.c < prev    next >
Encoding:
Text File  |  1986-11-30  |  330 b   |  24 lines

  1. /*
  2.  * Concatenate s2 on the end of s1.  S1's space must be large enough.
  3.  * At most n characters are moved.
  4.  * Return s1.
  5.  */
  6.  
  7. strncat(s1, s2, n)
  8. register char *s1, *s2;
  9. register n;
  10. {
  11.     register char *os1;
  12.  
  13.     os1 = s1;
  14.     while (*s1++)
  15.         ;
  16.     --s1;
  17.     while (*s1++ = *s2++)
  18.         if (--n < 0) {
  19.             *--s1 = '\0';
  20.             break;
  21.         }
  22.     return(os1);
  23. }
  24.