home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_10 / 1010016a < prev    next >
Text File  |  1992-08-12  |  382b  |  19 lines

  1.  
  2. Listing 4 -- the file strncat.c
  3.  
  4. /* strncat function */
  5. #include <string.h>
  6.  
  7. char *(strncat)(char *s1, const char *s2, size_t n)
  8.     {    /* copy char s2[max n] to end of s1[] */
  9.     char *s;
  10.  
  11.     for (s = s1; *s != '\0'; ++s)
  12.         ;                /* find end of s1[] */
  13.     for (; 0 < n && *s2 != '\0'; --n)
  14.         *s++ = *s2++;    /* copy at most n chars from s2[] */
  15.     *s = '\0';
  16.     return (s1);
  17.     }
  18.  
  19.