.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:11:47 1993 by Rik Faith (faith@cs.unc.edu) .\" 2007-06-15, Marc Boyer + mtk .\" Improve discussion of strncat(). .\" .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi .\" all rights reserved. .\" Translated Mon Jan 20 22:47:14 JST 1997 .\" by YOSHINO Takashi .\" Updated & Modified Fri Feb 18 00:30:00 JST 2005 .\" by Yuichi SATO .\" Updated 2007-07-04, Akihiro MOTOKI , LDP v2.58 .\" .TH STRCAT 3 2010-09-20 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O strcat, strncat \- concatenate two strings strcat, strncat \- 二つの文字列を連結する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "char *strcat(char *" dest ", const char *" src ); .sp .BI "char *strncat(char *" dest ", const char *" src ", size_t " n ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR strcat () .\"O function appends the \fIsrc\fP string to the .\"O \fIdest\fP string, overwriting the null byte (\(aq\\0\(aq) at the end of .\"O \fIdest\fP, and then adds a terminating null byte. .\"O The strings may not overlap, and the \fIdest\fP string must have .\"O enough space for the result. .BR strcat () 関数は、\fIdest\fP 文字列の後に \fIsrc\fP 文字列を付け加える。 その際に、\fIdest\fP の最後にあるヌルバイト (\(aq\\0\(aq) は上書きされ、 新たに生成された文字列の末尾に終端のヌルバイトが付与される。 二つの文字列 \fIsrc\fP と \fIdest\fP は重なってはならない。 また、文字列 \fIdest\fP は、連結後の結果を格納するのに 十分な大きさでなければならない。 .PP .\"O The .\"O .BR strncat () .\"O function is similar, except that .\"O .IP * 3 .\"O it will use at most \fIn\fP characters from \fIsrc\fP; and .\"O .IP * .\"O \fIsrc\fP does not need to be null-terminated if it contains .\"O \fIn\fP or more characters. .BR strncat () も同様だが、以下の点が異なる。 .IP * 3 \fIsrc\fP のうち最大 \fIn\fP 文字が使用される。 .IP * \fIsrc\fP が \fIn\fP 文字以上の場合、 \fIsrc\fP はヌル終端されている必要はない。 .PP .\"O As with .\"O .BR strcat (), .\"O the resulting string in \fIdest\fP is always null-terminated. .BR strcat () と同じく、\fIdest\fP に格納される結果の文字列は常にヌル終端される。 .PP .\"O If \fIsrc\fP contains \fIn\fP or more characters, .\"O .BR strncat () .\"O writes \fIn+1\fP characters to \fIdest\fP (\fIn\fP .\"O from \fIsrc\fP plus the terminating null byte). .\"O Therefore, the size of \fIdest\fP must be at least .\"O \fIstrlen(dest)+n+1\fP. \fIsrc\fP が \fIn\fP 文字以上の場合、 .BR strncat () は \fIdest\fP に \fIn+1\fP 文字を書き込む (\fIsrc\fP からの \fIn\fP 文字と終端のヌルバイトである)。 したがって、\fIdest\fP の大きさは最低でも \fIstrlen(dest)+n+1\fP でなければならない。 .\"O A simple implementation of .\"O .BR strncat () .\"O might be: .BR strncat () の簡単な実装は以下のような感じであろう: .in +4n .nf char* strncat(char *dest, const char *src, size_t n) { size_t dest_len = strlen(dest); size_t i; for (i = 0 ; i < n && src[i] != \(aq\\0\(aq ; i++) dest[dest_len + i] = src[i]; dest[dest_len + i] = \(aq\\0\(aq; return dest; } .fi .in .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR strcat () .\"O and .\"O .BR strncat () .\"O functions return a pointer to the resulting string \fIdest\fP. .BR strcat () 関数と .BR strncat () 関数は、結果としてできる文字列 \fIdest\fP へのポインタを返す。 .\"O .SH "CONFORMING TO" .SH 準拠 SVr4, 4.3BSD, C89, C99. .\"O .SH "SEE ALSO" .SH 関連項目 .BR bcopy (3), .BR memccpy (3), .BR memcpy (3), .BR strcpy (3), .BR string (3), .BR strncpy (3), .BR wcscat (3), .BR wcsncat (3)