mount_setattr.2: ffix
[man-pages.git] / man3 / stpncpy.3
blob65501bf8d2fed2d3f349f628aa743bd6fba3aad5
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\" %%%LICENSE_END
9 .\"
10 .\" References consulted:
11 .\"   GNU glibc-2 source code and manual
12 .\"
13 .\" Corrected, aeb, 990824
14 .TH STPNCPY 3  2021-03-22 "GNU" "Linux Programmer's Manual"
15 .SH NAME
16 stpncpy \- copy a fixed-size string, returning a pointer to its end
17 .SH SYNOPSIS
18 .nf
19 .B #include <string.h>
20 .PP
21 .BI "char *stpncpy(char *restrict " dest ", const char *restrict " src \
22 ", size_t " n );
23 .fi
24 .PP
25 .RS -4
26 Feature Test Macro Requirements for glibc (see
27 .BR feature_test_macros (7)):
28 .RE
29 .PP
30 .BR stpncpy ():
31 .nf
32     Since glibc 2.10:
33         _POSIX_C_SOURCE >= 200809L
34     Before glibc 2.10:
35         _GNU_SOURCE
36 .fi
37 .SH DESCRIPTION
38 The
39 .BR stpncpy ()
40 function copies at most
41 .I n
42 characters from the string
43 pointed to by
44 .IR src ,
45 including the terminating null byte (\(aq\e0\(aq),
46 to the array pointed to by
47 .IR dest .
48 Exactly
49 .I n
50 characters are written at
51 .IR dest .
52 If the length
53 .I strlen(src)
54 is smaller than
55 .IR n ,
56 the
57 remaining characters in the array pointed to by
58 .I dest
59 are filled
60 with null bytes (\(aq\e0\(aq),
61 If the length
62 .I strlen(src)
63 is greater than or equal to
64 .IR n ,
65 the string pointed to by
66 .I dest
67 will
68 not be null-terminated.
69 .PP
70 The strings may not overlap.
71 .PP
72 The programmer must ensure that there is room for at least
73 .I n
74 characters
76 .IR dest .
77 .SH RETURN VALUE
78 .BR stpncpy ()
79 returns a pointer to the terminating null byte
81 .IR dest ,
82 or, if
83 .I dest
84 is not null-terminated,
85 .IR dest + n .
86 .SH ATTRIBUTES
87 For an explanation of the terms used in this section, see
88 .BR attributes (7).
89 .ad l
90 .nh
91 .TS
92 allbox;
93 lbx lb lb
94 l l l.
95 Interface       Attribute       Value
97 .BR stpncpy ()
98 T}      Thread safety   MT-Safe
99 .TE
102 .sp 1
103 .SH CONFORMING TO
104 This function was added to POSIX.1-2008.
105 Before that, it was a GNU extension.
106 It first appeared in version 1.07 of the GNU C library in 1993.
107 .SH SEE ALSO
108 .BR strncpy (3),
109 .BR wcpncpy (3)