字符串连接函数:strcat()
字符串复制函数:strcpy()
注意,需要引用 #include<string.h> 头文件
#include<stdio.h>
#include<string.h>
void main(){
char str1[]="abc";
char str2[]="XYZ";
// strcpy()复制str2的值,从str1开始覆盖
strcpy(str1+2,str2);
printf("%s",str1);
printf("\n");
char str3[]="123";
char str4[]="qqq";
// strcat()将str4字符串连接到str3字符串之后
strcat(str3,str4);
printf("%s",str3);
}
运行结果: