1STPNCPY(3) Linux Programmer's Manual STPNCPY(3)
2
3
4
6 stpncpy - copy a fixed-size string, returning a pointer to its end
7
9 #include <string.h>
10
11 char *stpncpy(char *dest, const char *src, size_t n);
12
13 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15 stpncpy():
16 Since glibc 2.10:
17 _POSIX_C_SOURCE >= 200809L
18 Before glibc 2.10:
19 _GNU_SOURCE
20
22 The stpncpy() function copies at most n characters from the string
23 pointed to by src, including the terminating null byte ('\0'), to the
24 array pointed to by dest. Exactly n characters are written at dest.
25 If the length strlen(src) is smaller than n, the remaining characters
26 in the array pointed to by dest are filled with null bytes ('\0'), If
27 the length strlen(src) is greater than or equal to n, the string
28 pointed to by dest will not be null-terminated.
29
30 The strings may not overlap.
31
32 The programmer must ensure that there is room for at least n characters
33 at dest.
34
36 stpncpy() returns a pointer to the terminating null byte in dest, or,
37 if dest is not null-terminated, dest+n.
38
40 For an explanation of the terms used in this section, see
41 attributes(7).
42
43 ┌──────────┬───────────────┬─────────┐
44 │Interface │ Attribute │ Value │
45 ├──────────┼───────────────┼─────────┤
46 │stpncpy() │ Thread safety │ MT-Safe │
47 └──────────┴───────────────┴─────────┘
49 This function was added to POSIX.1-2008. Before that, it was a GNU
50 extension. It first appeared in version 1.07 of the GNU C library in
51 1993.
52
54 strncpy(3), wcpncpy(3)
55
57 This page is part of release 4.15 of the Linux man-pages project. A
58 description of the project, information about reporting bugs, and the
59 latest version of this page, can be found at
60 https://www.kernel.org/doc/man-pages/.
61
62
63
64GNU 2016-03-15 STPNCPY(3)