C-standard-library-c-function-strcat
提供:Dev Guides
Cライブラリ関数-strcat()
説明
Cライブラリ関数 char strcat(char dest、const char src)は、 *src が指す文字列を dest が指す文字列の末尾に追加します。
宣言
以下は、strcat()関数の宣言です。
char *strcat(char *dest, const char *src)
パラメーター
- dest -これは、Cの文字列を含む宛先配列へのポインタであり、連結された結果の文字列を含むのに十分な大きさでなければなりません。
- src -これは追加される文字列です。 これは宛先とオーバーラップしてはなりません。
戻り値
この関数は、結果の文字列destへのポインタを返します。
例
次の例は、strcat()関数の使用法を示しています。
#include <stdio.h>
#include <string.h>
int main () {
char src[50], dest[50];
strcpy(src, "This is source");
strcpy(dest, "This is destination");
strcat(dest, src);
printf("Final destination string : |%s|", dest);
return(0);
}
次の結果を生成する上記のプログラムをコンパイルして実行しましょう-
Final destination string : |This is destinationThis is source|