OSDN Git Service

15fff2f1a985a0d8a3250a0f5a2e0ecb58471ca1
[linuxjm/LDP_man-pages.git] / draft / man3 / strcat.3
1 .\" Copyright 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:11:47 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" 2007-06-15, Marc Boyer <marc.boyer@enseeiht.fr> + mtk
29 .\"     Improve discussion of strncat().
30 .\"*******************************************************************
31 .\"
32 .\" This file was generated with po4a. Translate the source file.
33 .\"
34 .\"*******************************************************************
35 .TH STRCAT 3 2011\-09\-28 GNU "Linux Programmer's Manual"
36 .SH 名前
37 strcat, strncat \- 二つの文字列を連結する
38 .SH 書式
39 .nf
40 \fB#include <string.h>\fP
41 .sp
42 \fBchar *strcat(char *\fP\fIdest\fP\fB, const char *\fP\fIsrc\fP\fB);\fP
43 .sp
44 \fBchar *strncat(char *\fP\fIdest\fP\fB, const char *\fP\fIsrc\fP\fB, size_t \fP\fIn\fP\fB);\fP
45 .fi
46 .SH 説明
47 \fBstrcat\fP()  関数は、\fIdest\fP 文字列の後に \fIsrc\fP 文字列を付け加える。 その際に、\fIdest\fP の最後にある終端の
48 NULL バイト (\(aq\e0\(aq)  は上書きされ、新たに生成された文字列の末尾に終端の NULL バイトが付与される。 二つの文字列
49 \fIsrc\fP と \fIdest\fP は重なってはならない。 また、文字列 \fIdest\fP は、連結後の結果を格納するのに 十分な大きさでなければならない。
50 .PP
51 \fBstrncat\fP()  も同様だが、以下の点が異なる。
52 .IP * 3
53 \fIsrc\fP のうち最大 \fIn\fP 文字が使用される。
54 .IP *
55 \fIsrc\fP が \fIn\fP 文字以上の場合、 \fIsrc\fP は NULL 終端されている必要はない。
56 .PP
57 \fBstrcat\fP()  と同じく、\fIdest\fP に格納される結果の文字列は常に NULL 終端される。
58 .PP
59 \fIsrc\fP が \fIn\fP 文字以上の場合、 \fBstrncat\fP()  は \fIdest\fP に \fIn+1\fP 文字を書き込む (\fIsrc\fP からの
60 \fIn\fP 文字と終端の NULL バイトである)。 したがって、\fIdest\fP の大きさは最低でも \fIstrlen(dest)+n+1\fP
61 でなければならない。
62
63 \fBstrncat\fP()  の簡単な実装は以下のような感じであろう:
64 .in +4n
65 .nf
66
67 char*
68 strncat(char *dest, const char *src, size_t n)
69 {
70     size_t dest_len = strlen(dest);
71     size_t i;
72
73     for (i = 0 ; i < n && src[i] != \(aq\e0\(aq ; i++)
74         dest[dest_len + i] = src[i];
75     dest[dest_len + i] = \(aq\e0\(aq;
76
77     return dest;
78 }
79 .fi
80 .in
81 .SH 返り値
82 \fBstrcat\fP()  関数と \fBstrncat\fP()  関数は、結果としてできる文字列 \fIdest\fP へのポインタを返す。
83 .SH 準拠
84 SVr4, 4.3BSD, C89, C99.
85 .SH 関連項目
86 \fBbcopy\fP(3), \fBmemccpy\fP(3), \fBmemcpy\fP(3), \fBstrcpy\fP(3), \fBstring\fP(3),
87 \fBstrncpy\fP(3), \fBwcscat\fP(3), \fBwcsncat\fP(3)