home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / strncat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.2 KB  |  66 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strncat.c,v 1.1 1996/12/11 11:24:46 aros Exp $
  4.  
  5.     Desc: ANSI C function strncat()
  6.     Lang: english
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME */
  12. #include <string.h>
  13.  
  14.     char * strncat (
  15.  
  16. /*  SYNOPSIS */
  17.     char       * dest,
  18.     const char * src,
  19.     size_t         n)
  20.  
  21. /*  FUNCTION
  22.     Concatenates two strings. If src is longer than n characters, then
  23.     only the first n characters are copied.
  24.  
  25.     INPUTS
  26.     dest - src is appended to this string. Make sure that there
  27.         is enough room for src.
  28.     src - This string is appended to dest
  29.     n - No more than this number of characters of src are copied.
  30.  
  31.     RESULT
  32.     dest.
  33.  
  34.     NOTES
  35.     The routine makes no checks if dest is large enough. The size of
  36.     dest must be at least strlen(dest)+n+1.
  37.  
  38.     EXAMPLE
  39.     char buffer[64];
  40.  
  41.     strcpy (buffer, "Hello ");
  42.     strncat (buffer, "World.!!", 6);
  43.  
  44.     // Buffer now contains "Hello World."
  45.  
  46.     BUGS
  47.  
  48.     SEE ALSO
  49.  
  50.     INTERNALS
  51.  
  52.     HISTORY
  53.  
  54. ******************************************************************************/
  55. {
  56.     char * d = dest;
  57.  
  58.     while (*dest)
  59.     dest ++;
  60.  
  61.     while (n && (*dest ++ = *src ++))
  62.     n --;
  63.  
  64.     return d;
  65. } /* strncat */
  66.