revert between 56095 -> 55830 in arch
[AROS.git] / compiler / stdc / strncpy.c
blob86f2cdaa957561dcd85022cbb97a4b2be66c58cd
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function strncpy().
6 */
8 /*****************************************************************************
10 NAME */
11 #include <string.h>
13 char * strncpy (
15 /* SYNOPSIS */
16 char * dest,
17 const char * src,
18 size_t n)
20 /* FUNCTION
21 Copy a string. Works like an assignment "dest=src;". At most
22 n characters are copied.
24 INPUTS
25 dest - The string is copied into this variable. Make sure it is
26 large enough.
27 src - This is the new contents of dest.
28 n - How many characters to copy at most. If the string src is
29 smaller than that, only strlen(str)+1 bytes are copied.
31 RESULT
32 dest.
34 NOTES
35 No check is made that dest is large enough for src.
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 strncpy(), memcpy(), memmove()
44 INTERNALS
46 ******************************************************************************/
48 char * ptr = dest;
50 while (n && (*ptr = *src))
52 ptr ++;
53 src ++;
54 n--;
57 while (n--)
58 *ptr++ = '\0';
60 return dest;
61 } /* strncpy */