Commit | Line | Data |
---|---|---|
41b85a03 KB |
1 | .\" Copyright (c) 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" Chris Torek. | |
6 | .\" | |
7 | .\" %sccs.include.redist.man% | |
8 | .\" | |
9 | .\" @(#)strncpy.3 5.1 (Berkeley) %G% | |
10 | .\" | |
11 | .TH STRNCPY 3 "" | |
12 | .UC 4 | |
13 | .SH NAME | |
14 | strncpy \- copy strings of limited length | |
15 | .SH SYNOPSIS | |
16 | .nf | |
17 | .ft B | |
18 | #include <string.h> | |
19 | ||
20 | char * | |
21 | strncpy(char *dst, const char *src, size_t len); | |
22 | .ft R | |
23 | .fi | |
24 | .SH DESCRIPTION | |
25 | .B Strncpy | |
26 | writes exactly | |
27 | .I len | |
28 | characters into | |
29 | .I dst | |
30 | by copying string | |
31 | .I src | |
32 | to | |
33 | .IR dst , | |
34 | appending '\e0' characters if | |
35 | .I src | |
36 | is less than | |
37 | .I len | |
38 | characters long, and | |
39 | .I not | |
40 | terminating | |
41 | .I dst | |
42 | if | |
43 | .I src | |
44 | is more than | |
45 | .I len | |
46 | characters long. | |
47 | .B Strncpy | |
48 | returns | |
49 | .IR dst . | |
50 | .SH EXAMPLES | |
51 | The following sets ``chararray'' to ``abc\e0\e0\e0'': | |
52 | .sp | |
53 | .ti +0.5i | |
54 | (void)strncpy(chararray, "abc", 6). | |
55 | .PP | |
56 | The following sets ``chararray'' to ``abcdef'': | |
57 | .sp | |
58 | .RS | |
59 | (void)strncpy(chararray, "abcdefgh", 6); | |
60 | .RE | |
61 | .SH SEE ALSO | |
62 | bcopy(3), memccpy(3), memcpy(3), memmove(3), strcpy(3) | |
63 | .SH STANDARDS | |
64 | .B Strncpy | |
65 | conforms to ANSI X3.159-1989 (``ANSI C''). |