OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man3 / strcpy.3
1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 18:06:49 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Fri Aug 25 23:17:51 1995 by Andries Brouwer (aeb@cwi.nl)
29 .\" Modified Wed Dec 18 00:47:18 1996 by Andries Brouwer (aeb@cwi.nl)
30 .\" 2007-06-15, Marc Boyer <marc.boyer@enseeiht.fr> + mtk
31 .\"     Improve discussion of strncpy().
32 .\"
33 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
34 .\"       all rights reserved.
35 .\" Translated Mon Jan 20 22:35:40 JST 1997
36 .\"       by YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
37 .\"
38 .\" Japanese Version Last Modified Sun Sep 5 01:48:52 1999
39 .\"     by Kentaro Shirakata <argrath@yo.rim.or.jp>
40 .\" Modified for 'null/NUL translation' Sat 5 Jan 2002
41 .\"     by NAKANO Takeo <nakano@apm.seikei.ac.jp
42 .\" Updated 2007-07-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.58
43 .\"
44 .TH STRCPY 3  2009-12-04 "GNU" "Linux Programmer's Manual"
45 .SH Ì¾Á°
46 strcpy, strncpy \- Ê¸»úÎó¤ò¥³¥Ô¡¼¤¹¤ë
47 .SH ½ñ¼°
48 .nf
49 .B #include <string.h>
50 .sp
51 .BI "char *strcpy(char *" dest ", const char *" src );
52 .sp
53 .BI "char *strncpy(char *" dest ", const char *" src ", size_t " n );
54 .fi
55 .SH ÀâÌÀ
56 .BR strcpy ()
57 ´Ø¿ô¤Ï
58 \fIsrc\fP ¤¬»Ø¤¹Ê¸»úÎó¤òËöÈø¤Î¥Ì¥ë¥Ð¥¤¥È (\(aq\\0\(aq) ¤â´Þ¤á¤Æ
59 \fIdest\fP ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë¥³¥Ô¡¼¤¹¤ë¡£
60 Æó¤Ä¤Îʸ»úÎó¤Ï½Å¤Ê¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¼õ¤±Â¦¤Îʸ»úÎó \fIdest\fP ¤Ï
61 ¥³¥Ô¡¼¤ò¼õ¤±¼è¤ë¤Î¤Ë½½Ê¬¤ÊÂ礭¤µ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
62 .PP
63 .BR strncpy ()
64 ´Ø¿ô¤âƱÍͤÀ¤¬¡¢
65 \fIsrc\fP ¤Î¤¦¤ÁºÇÂç¤Ç¤â \fIn\fP ¥Ð¥¤¥È¤·¤«¥³¥Ô¡¼¤µ¤ì¤Ê¤¤ÅÀ¤¬°Û¤Ê¤ë¡£
66 .BR ·Ù¹ð :
67 \fIsrc\fP ¤ÎºÇ½é¤Î \fIn\fP ¥Ð¥¤¥È¤ÎÃæ¤Ë¥Ì¥ë¥Ð¥¤¥È¤¬¤Ê¤¤¾ì¹ç¡¢
68 \fIdest\fP ¤Ë³ÊǼ¤µ¤ì¤ëʸ»úÎó¤Ï¥Ì¥ë¤Ç½ªÃ¼¤µ¤ì¤Ê¤¤¤³¤È¤Ë¤Ê¤ë¡£
69 .PP
70 .I src
71 ¤ÎŤµ¤¬
72 .I n
73 ¤è¤ê¤âû¤¤¾ì¹ç¡¢
74 .BR strncpy ()
75 ¤Ï
76 .I dest
77 ¤Î»Ä¤ê¤ò¥Ì¥ë¥Ð¥¤¥È¤ÇËä¤á¤ë¡£
78 .PP
79 .BR strncpy ()
80 ¤Î´Êñ¤Ê¼ÂÁõ¤Ï°Ê²¼¤Î¤è¤¦¤Ê´¶¤¸¤Ç¤¢¤í¤¦:
81 .in +4n
82 .nf
83
84 char*
85 strncpy(char *dest, const char *src, size_t n){
86     size_t i;
87
88     for (i = 0 ; i < n && src[i] != \(aq\\0\(aq ; i++)
89         dest[i] = src[i];
90     for ( ; i < n ; i++)
91         dest[i] = \(aq\\0\(aq;
92
93     return dest;
94 }
95 .fi
96 .in
97 .SH ÊÖ¤êÃÍ
98 .BR strcpy ()
99 ´Ø¿ô¤È
100 .BR strncpy ()
101 ´Ø¿ô¤Ï
102 ¼õ¤±Â¦¤Îʸ»úÎó\fIdest\fP¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
103 .SH ½àµò
104 SVr4, 4.3BSD, C89, C99.
105 .SH Ãí°Õ
106 .BR strncpy ()
107 ¤Ï¸úΨŪ¤Ç¤Ê¤¯´Ö°ã¤¤¤òµ¯¤³¤·¤ä¤¹¤¤¤È¹Í¤¨¤ë¥×¥í¥°¥é¥Þ¤â¤¤¤ë¤À¤í¤¦¡£
108 ¥×¥í¥°¥é¥Þ¤¬ \fIdest\fP ¤ÎÂ礭¤µ¤¬ \fIsrc\fP ¤ÎŤµ¤è¤ê¤â
109 Â礭¤¤¤³¤È¤òÃΤäƤ¤¤ë (¤Ä¤Þ¤ê¡¢¤½¤Î¤³¤È¤ò¥Á¥§¥Ã¥¯¤¹¤ë¥³¡¼¥É¤ò
110 ½ñ¤¤¤Æ¤¤¤ë) ¾ì¹ç¤Ï¡¢
111 .B strcpy()
112 ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
113
114 \fIsrc\fP ¤ÎºÇ½é¤Î \fIn\fP Ê¸»ú¤Ë½ªÃ¼¤Î¥Ì¥ë¥Ð¥¤¥È¤¬¤Ê¤¤¾ì¹ç¡¢
115 .BR strncpy ()
116 ¤Ï \fIdest\fP ¤Ë½ªÃ¼¤µ¤ì¤Æ¤¤¤Ê¤¤Ê¸»úÎó¤òÀ¸À®¤¹¤ë¡£
117 ¥×¥í¥°¥é¥Þ¤Ï´Ö°ã¤¤¤òËɻߤ¹¤ë¤¿¤á¤Ë¡¢
118 °Ê²¼¤Î¤è¤¦¤Ë¶¯À©Åª¤Ë½ªÃ¼¤ò¹Ô¤¦¤³¤È¤¬¤è¤¯¤¢¤ë¡£
119 .in +4n
120 .nf
121
122 strncpy(buf, str, n);
123 if (n > 0)
124     buf[n \- 1]= \(aq\\0\(aq;
125 .fi
126 .in
127 .SH ¥Ð¥°
128 .BR strcpy ()
129 ¤Î¼õ¤±Â¦¤Îʸ»úÎ󤬽½Ê¬¤ÊÂ礭¤µ¤Ç¤Ê¤¤¾ì¹ç¡¢²¿¤¬µ¯¤³¤ë¤«¤ï¤«¤é¤Ê¤¤¡£
130 ¸ÇÄêĹʸ»úÎó¤ò°î¤ì¤µ¤»¤ë¤Î¤Ï¡¢¥Þ¥·¥ó¤ÎÀ©¸æ¤ò¾¸Ãæ¤Ë¼ý¤á¤ë¤¿¤á¤Ë
131 ¥¯¥é¥Ã¥«¡¼¤¬¹¥¤ó¤Ç»È¤¦¥Æ¥¯¥Ë¥Ã¥¯¤Ç¤¢¤ë¡£
132 ¥×¥í¥°¥é¥à¤Ç¥Ç¡¼¥¿¤ò¥Ð¥Ã¥Õ¥¡¤ËÆɤ߹þ¤ó¤À¤ê¥³¥Ô¡¼¤·¤¿¤ê¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢
133 ɬ¤º¤Þ¤ººÇ½é¤Ë½½Ê¬¤ÊÂ礭¤µ¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ëɬÍפ¬¤¢¤ë¡£
134 ¥×¥í¥°¥é¥Þ¤¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤¬ÉÔ²Äǽ¤À¤È¼¨¤»¤ë¾ì¹ç¤Ë¤Ï
135 ¤³¤Î¥Á¥§¥Ã¥¯¤ÏÉÔÍפ«¤â¤·¤ì¤Ê¤¤¤¬¡¢½½Ê¬Ãí°Õ¤¹¤ë¤³¤È¡£
136 Ť¤´Ö¤Ë¤Ï¡¢ÉÔ²Äǽ¤À¤Ã¤¿¤³¤È¤¬²Äǽ¤Ë¤Ê¤ë¤è¤¦¤ÊÊýË¡¤Ç¥×¥í¥°¥é¥à¤¬
137 Êѹ¹¤µ¤ì¤ë¤³¤È¤â¤¢¤ë¤«¤é¤À¡£
138 .SH ´ØÏ¢¹àÌÜ
139 .BR bcopy (3),
140 .BR memccpy (3),
141 .BR memcpy (3),
142 .BR memmove (3),
143 .BR stpcpy (3),
144 .BR strdup (3),
145 .BR wcscpy (3),
146 .BR wcsncpy (3)