--
#include <stdio.h>
void Bind_Str(char *s1, char *s2);
int main(void)
{
char str1[100] = "Hello";
char str2[]="World";
Bind_Str(str1, str2);
printf("%s\r\n", str1);
return 0;
}
// 文字列s1に文字列s2を付加する。
void Bind_Str(char *s1, char *s2)
{
while(*s1) s1++; // s1ポインタをNULLまで進める。
while(*s2)
{
*s1 = *s2; // s2先頭からs1へ一文字ずつ付加。
s1++;
s2++;
}
*s1 = '\0'; //末端にNULL付加
}