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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       strncpy - copy part of a string
13

SYNOPSIS

15       #include <string.h>
16
17       char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
18
19

DESCRIPTION

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

RETURN VALUE

31       The  strncpy() function shall return s1; no return value is reserved to
32       indicate an error.
33

ERRORS

35       No errors are defined.
36
37       The following sections are informative.
38

EXAMPLES

40       None.
41

APPLICATION USAGE

43       Character movement is performed differently  in  different  implementa‐
44       tions.  Thus, overlapping moves may yield surprises.
45
46       If  there  is no null byte in the first n bytes of the array pointed to
47       by s2, the result is not null-terminated.
48

RATIONALE

50       None.
51

FUTURE DIRECTIONS

53       None.
54

SEE ALSO

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