OSDN Git Service

b5bbe2249ca8a6e0759b953db4000211d955f317
[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  2014-01-13 "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
46 .I n
47 characters from the string
48 pointed to by
49 .IR src ,
50 including the terminating null byte (\(aq\\0\(aq),
51 to the array pointed to by
52 .IR dest .
53 Exactly
54 .I n
55 characters are written at
56 .IR dest .
57 If the length
58 .I strlen(src)
59 is smaller than
60 .IR n ,
61 the
62 remaining characters in the array pointed to by
63 .I dest
64 are filled
65 with null bytes (\(aq\\0\(aq),
66 If the length
67 .I strlen(src)
68 is greater than or equal to
69 .IR n ,
70 the string pointed to by
71 .I dest
72 will
73 not be null-terminated.
74 .PP
75 The strings may not overlap.
76 .PP
77 The programmer must ensure that there is room for at least
78 .I n
79 characters
80 at
81 .IR dest .
82 .SH RETURN VALUE
83 .BR stpncpy ()
84 returns a pointer to the terminating null byte
85 in
86 .IR dest ,
87 or, if
88 .I dest
89 is not null-terminated,
90 .IR dest + n .
91 .SH ATTRIBUTES
92 .SS Multithreading (see pthreads(7))
93 The
94 .BR stpncpy ()
95 function is thread-safe.
96 .SH CONFORMING TO
97 This function was added to POSIX.1-2008.
98 Before that, it was a GNU extension.
99 .SH SEE ALSO
100 .BR strncpy (3),
101 .BR wcpncpy (3)
102 .SH COLOPHON
103 This page is part of release 3.64 of the Linux
104 .I man-pages
105 project.
106 A description of the project,
107 and information about reporting bugs,
108 can be found at
109 \%http://www.kernel.org/doc/man\-pages/.