😸
[C] strcat 関数
機能
文字列を結合する関数[1]
使用例
"Hello, World!"
と表示する
\n
は改行を表す エスケープシーケンス[2]
コード
char str[20] = "Hello, ";
strcat(str, "World!");
printf("%s\n", str);
全文
#include <stdio.h>
#include <string.h>
void main() {
char str[20] = "Hello, ";
strcat(str, "World!");
printf("%s\n", str);
}
実行結果
Hello, World!
"Goodbye, World!"
を表示する
変数から コード
char str1[20] = "Goodbye, ";
char str2[] = "World!";
strcat(str1, str2);
printf("%s\n", str1);
全文
#include <stdio.h>
#include <string.h>
void main() {
char str1[20] = "Goodbye, ";
char str2[] = "World!";
strcat(str1, str2);
printf("%s\n", str1);
}
実行結果
Goodbye, World!
Discussion