1STRNCPY(P)                 POSIX Programmer's Manual                STRNCPY(P)
2
3
4

NAME

6       strncpy - copy part of a string
7

SYNOPSIS

9       #include <string.h>
10
11       char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
12
13

DESCRIPTION

15       The  strncpy()  function  shall  copy not more than n bytes (bytes that
16       follow a null byte are not copied) from the array pointed to by  s2  to
17       the  array  pointed  to  by s1.  If copying takes place between objects
18       that overlap, the behavior is undefined.
19
20       If the array pointed to by s2 is a string that is shorter than n bytes,
21       null bytes shall be appended to the copy in the array pointed to by s1,
22       until n bytes in all are written.
23

RETURN VALUE

25       The strncpy() function shall return s1; no return value is reserved  to
26       indicate an error.
27

ERRORS

29       No errors are defined.
30
31       The following sections are informative.
32

EXAMPLES

34       None.
35

APPLICATION USAGE

37       Character  movement  is  performed differently in different implementa‐
38       tions.  Thus, overlapping moves may yield surprises.
39
40       If there is no null byte in the first n bytes of the array  pointed  to
41       by s2, the result is not null-terminated.
42

RATIONALE

44       None.
45

FUTURE DIRECTIONS

47       None.
48

SEE ALSO

50       strcpy()   ,  the  Base  Definitions  volume  of  IEEE Std 1003.1-2001,
51       <string.h>
52
54       Portions of this text are reprinted and reproduced in  electronic  form
55       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
56       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
57       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
58       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
59       event of any discrepancy between this version and the original IEEE and
60       The Open Group Standard, the original IEEE and The Open Group  Standard
61       is  the  referee document. The original Standard can be obtained online
62       at http://www.opengroup.org/unix/online.html .
63
64
65
66IEEE/The Open Group                  2003                           STRNCPY(P)
Impressum