1STPNCPY(3)                 Linux Programmer's Manual                STPNCPY(3)
2
3
4

NAME

6       stpncpy - copy a fixed-size string, returning a pointer to its end
7

SYNOPSIS

9       #include <string.h>
10
11       char *stpncpy(char *restrict dest, const char *restrict 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

DESCRIPTION

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

RETURN VALUE

36       stpncpy() returns a pointer to the terminating null byte in  dest,  or,
37       if dest is not null-terminated, dest+n.
38

ATTRIBUTES

40       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
41       tributes(7).
42
43       ┌────────────────────────────────────────────┬───────────────┬─────────┐
44Interface                                   Attribute     Value   
45       ├────────────────────────────────────────────┼───────────────┼─────────┤
46stpncpy()                                   │ Thread safety │ MT-Safe │
47       └────────────────────────────────────────────┴───────────────┴─────────┘
48

CONFORMING TO

50       This function was added to POSIX.1-2008.  Before that, it was a GNU ex‐
51       tension.   It  first  appeared  in version 1.07 of the GNU C library in
52       1993.
53

SEE ALSO

55       strncpy(3), wcpncpy(3)
56

COLOPHON

58       This page is part of release 5.13 of the Linux  man-pages  project.   A
59       description  of  the project, information about reporting bugs, and the
60       latest    version    of    this    page,    can     be     found     at
61       https://www.kernel.org/doc/man-pages/.
62
63
64
65GNU                               2021-03-22                        STPNCPY(3)
Impressum