//模拟字符串函数strcat
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
char* MyStrcat(char* s1, const char* s2)
{
char* s3 = s1;
while (*s1 != '\0') //寻找字符串s1的 '\0'
{
s1++;
}
while (*s1++ = *s2++); //把s2的各个字符赋值给s1
return s3; //返回s1的首元素地址
}
int main()
{
char arr1[20] = "Hello ";
char arr2[20] = "World";
printf("%s", MyStrcat(arr1, arr2));
return 0;
}
11-15
2877
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)