]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
2 | .\" | |
3 | .\" This is free documentation; you can redistribute it and/or | |
4 | .\" modify it under the terms of the GNU General Public License as | |
5 | .\" published by the Free Software Foundation; either version 2 of | |
6 | .\" the License, or (at your option) any later version. | |
7 | .\" | |
8 | .\" References consulted: | |
9 | .\" GNU glibc-2 source code and manual | |
10 | .\" | |
11 | .\" Corrected, aeb, 990824 | |
71d9e7ae | 12 | .TH STPNCPY 3 2011-09-28 "GNU" "Linux Programmer's Manual" |
fea681da MK |
13 | .SH NAME |
14 | stpncpy \- copy a fixed-size string, returning a pointer to its end | |
15 | .SH SYNOPSIS | |
16 | .nf | |
fea681da MK |
17 | .B #include <string.h> |
18 | .sp | |
19 | .BI "char *stpncpy(char *" dest ", const char *" src ", size_t " n ); | |
20 | .fi | |
79247bb1 MK |
21 | .sp |
22 | .in -4n | |
23 | Feature Test Macro Requirements for glibc (see | |
24 | .BR feature_test_macros (7)): | |
25 | .in | |
26 | .sp | |
27 | .BR stpncpy (): | |
ea91c3fd MK |
28 | .PD 0 |
29 | .ad l | |
30 | .RS 4 | |
31 | .TP 4 | |
32 | Since glibc 2.10: | |
33 | _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L | |
34 | .TP | |
79247bb1 MK |
35 | Before glibc 2.10: |
36 | _GNU_SOURCE | |
ea91c3fd MK |
37 | .RE |
38 | .ad | |
39 | .PD | |
fea681da | 40 | .SH DESCRIPTION |
60a90ecd MK |
41 | The |
42 | .BR stpncpy () | |
43 | function copies at most \fIn\fP characters from the string | |
71d9e7ae | 44 | pointed to by \fIsrc\fP, including the terminating null byte (\(aq\\0\(aq), |
f81fb444 | 45 | to the array pointed to by \fIdest\fP. |
c13182ef MK |
46 | Exactly \fIn\fP characters are written at |
47 | \fIdest\fP. | |
48 | If the length \fIstrlen(src)\fP is smaller than \fIn\fP, the | |
fea681da | 49 | remaining characters in the array pointed to by \fIdest\fP are filled |
71d9e7ae | 50 | with null bytes (\(aq\\0\(aq), |
c13182ef | 51 | If the length \fIstrlen(src)\fP is greater or equal to |
f81fb444 | 52 | \fIn\fP, the string pointed to by \fIdest\fP will |
71d9e7ae | 53 | not be null-terminated. |
fea681da MK |
54 | .PP |
55 | The strings may not overlap. | |
56 | .PP | |
57 | The programmer must ensure that there is room for at least \fIn\fP characters | |
58 | at \fIdest\fP. | |
59 | .SH "RETURN VALUE" | |
60a90ecd | 60 | .BR stpncpy () |
aa198ef9 | 61 | returns a pointer to the terminating null byte |
fea681da MK |
62 | in \fIdest\fP, or, if \fIdest\fP is not null-terminated, |
63 | \fIdest + n\fP. | |
64 | .SH "CONFORMING TO" | |
268a3684 | 65 | This function was added to POSIX.1-2008. Before that, it was a GNU extension. |
fea681da | 66 | .SH "SEE ALSO" |
1709027c | 67 | .BR strncpy (3), |
0a4f8b7b | 68 | .BR wcpncpy (3) |