home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / STRNCAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.8 KB  |  50 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - strncat.c
  3.  *
  4.  * function(s)
  5.  *        strncat - appends strings
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #include <string.h>
  19. #include <mem.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            strncat - appends strings
  24.  
  25. Usage           char *strncat(char *destin, const char *source, size_t maxlen);
  26.  
  27. Prototype in    string.h
  28.  
  29. Description     strncat copies at most maxlen characters of source to the end
  30.                 of destin and then appends a null character. The maximum length
  31.                 of the resulting string is strlen(destin) + maxlen.
  32.  
  33. Return value    pointer to destin
  34.  
  35. *---------------------------------------------------------------------*/
  36. #undef strncat                  /* not an intrinsic */
  37. char *strncat(char *dest, const char *src, size_t maxlen)
  38. {
  39.     register unsigned len;
  40.     unsigned dlen;
  41.  
  42.     dlen = strlen(dest);
  43.     len = strlen(src);
  44.     if (len > maxlen)
  45.         len = maxlen;
  46.     movmem((void *)src, dest + dlen, len);
  47.     dest[dlen + len] = 0;
  48.     return (dest);
  49. }
  50.