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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strncpy.c,v 1.1 1996/12/11 11:18:27 aros Exp $
  4.  
  5.     Desc: ANSI C function strncpy()
  6.     Lang: english
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME */
  12. #include <string.h>
  13.  
  14.     char * strncpy (
  15.  
  16. /*  SYNOPSIS */
  17.     char       * dest,
  18.     const char * src,
  19.     size_t         n)
  20.  
  21. /*  FUNCTION
  22.     Copy a string. Works like an assignment "dest=src;". At most
  23.     n characters are copied.
  24.  
  25.     INPUTS
  26.     dest - The string is copied into this variable. Make sure it is
  27.         large enough.
  28.     src - This is the new contents of dest.
  29.     n - How many characters to copy at most. If the string src is
  30.         smaller than that, only strlen(str)+1 bytes are copied.
  31.  
  32.     RESULT
  33.     dest.
  34.  
  35.     NOTES
  36.     No check is beeing made that dest is large enough for src.
  37.  
  38.     EXAMPLE
  39.  
  40.     BUGS
  41.  
  42.     SEE ALSO
  43.     strncpy(), memcpy(), memmove()
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.     29.07.1996 digulla created
  49.  
  50. ******************************************************************************/
  51. {
  52.     char * ptr = dest;
  53.  
  54.     while (n && (*ptr = *src))
  55.     {
  56.     ptr ++;
  57.     src ++;
  58.  
  59.     n --;
  60.     }
  61.  
  62.     return dest;
  63. } /* strncpy */
  64.