home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / STRNCAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.4 KB  |  54 lines

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