home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / STRNCAT.C < prev    next >
Text File  |  1984-12-31  |  768b  |  27 lines

  1. /*  File   : strncat.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 20 April 1984
  4.     Defines: strncat()
  5.  
  6.     strncat(dst, src, n)  copies up to n characters of src to the end of
  7.     dst.   As with strcat, it has to search for the end of dst.  Even if
  8.     it abandons src early because n runs out it  will  still  close  dst
  9.     with a NUL.  See also strnmov.
  10. */
  11.  
  12. #include "strings.h"
  13.  
  14. char *strncat(dst, src, n)
  15.     register char *dst, *src;
  16.     register int n;
  17.     {
  18.     char *save;
  19.  
  20.     for (save = dst; *dst++; ) ;
  21.     for (--dst; --n >= 0; )
  22.         if (!(*dst++ = *src++)) return save;
  23.     *dst = NUL;
  24.     return save;
  25.     }
  26.