OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man3 / stpncpy.3
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  2011-09-28 "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 .sp
21 .BI "char *stpncpy(char *" dest ", const char *" src ", size_t " n );
22 .fi
23 .sp
24 .in -4n
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
27 .in
28 .sp
29 .BR stpncpy ():
30 .PD 0
31 .ad l
32 .RS 4
33 .TP 4
34 Since glibc 2.10:
35 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
36 .TP
37 Before glibc 2.10:
38 _GNU_SOURCE
39 .RE
40 .ad
41 .PD
42 .SH DESCRIPTION
43 The
44 .BR stpncpy ()
45 function copies at most \fIn\fP characters from the string
46 pointed to by \fIsrc\fP, including the terminating null byte (\(aq\\0\(aq),
47 to the array pointed to by \fIdest\fP.
48 Exactly \fIn\fP characters are written at
49 \fIdest\fP.
50 If the length \fIstrlen(src)\fP is smaller than \fIn\fP, the
51 remaining characters in the array pointed to by \fIdest\fP are filled
52 with null bytes (\(aq\\0\(aq),
53 If the length \fIstrlen(src)\fP is greater or equal to
54 \fIn\fP, the string pointed to by \fIdest\fP will
55 not be null-terminated.
56 .PP
57 The strings may not overlap.
58 .PP
59 The programmer must ensure that there is room for at least \fIn\fP characters
60 at \fIdest\fP.
61 .SH RETURN VALUE
62 .BR stpncpy ()
63 returns a pointer to the terminating null byte
64 in \fIdest\fP, or, if \fIdest\fP is not null-terminated,
65 \fIdest + n\fP.
66 .SH CONFORMING TO
67 This function was added to POSIX.1-2008. Before that, it was a GNU extension.
68 .SH SEE ALSO
69 .BR strncpy (3),
70 .BR wcpncpy (3)