Commit | Line | Data |
---|---|---|
657bdb9b 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 | .\" | |
ee7c1421 | 9 | .\" @(#)strcpy.3 5.2 (Berkeley) %G% |
657bdb9b KB |
10 | .\" |
11 | .TH STRCPY 3 "" | |
12 | .UC 4 | |
13 | .SH NAME | |
14 | strcpy \- copy strings | |
15 | .SH SYNOPSIS | |
16 | .nf | |
17 | .ft B | |
18 | #include <string.h> | |
19 | ||
20 | char * | |
21 | strcpy(char *dst, const char *src); | |
ee7c1421 KB |
22 | |
23 | char * | |
24 | strncpy(char *dst, const char *src, size_t len); | |
657bdb9b KB |
25 | .ft R |
26 | .fi | |
27 | .SH DESCRIPTION | |
28 | .B Strcpy | |
ee7c1421 KB |
29 | and |
30 | .B strncpy | |
31 | copy string | |
657bdb9b KB |
32 | .I src |
33 | to | |
34 | .IR dst , | |
35 | stopping after the terminating '\e0' has been moved. | |
ee7c1421 KB |
36 | .PP |
37 | .B Strncpy | |
38 | writes exactly | |
39 | .I len | |
40 | characters into | |
41 | .IR dst , | |
42 | appending '\e0' characters if | |
43 | .I src | |
44 | is less than | |
45 | .I len | |
46 | characters long, and | |
47 | .I not | |
48 | terminating | |
49 | .I dst | |
50 | if | |
51 | .I src | |
52 | is more than | |
53 | .I len | |
54 | characters long. | |
55 | .PP | |
657bdb9b | 56 | .B Strcpy |
ee7c1421 KB |
57 | and |
58 | .B strncpy | |
59 | return | |
657bdb9b | 60 | .IR dst . |
ee7c1421 KB |
61 | .SH EXAMPLES |
62 | The following sets ``chararray'' to ``abc\e0\e0\e0'': | |
63 | .sp | |
64 | .ti +0.5i | |
65 | (void)strncpy(chararray, "abc", 6). | |
66 | .PP | |
67 | The following sets ``chararray'' to ``abcdef'': | |
68 | .sp | |
69 | .RS | |
70 | (void)strncpy(chararray, "abcdefgh", 6); | |
71 | .RE | |
657bdb9b | 72 | .SH SEE ALSO |
ee7c1421 | 73 | bcopy(3), memccpy(3), memcpy(3), memmove(3) |
657bdb9b KB |
74 | .SH STANDARDS |
75 | .B Strcpy | |
ee7c1421 KB |
76 | and |
77 | .B strncpy | |
78 | conform to ANSI X3.159-1989 (``ANSI C''). |