在C语言中,可以使用strcat函数来将字符串连接起来。strcat函数的原型为:
char* strcat(char* destination, const char* source);
其中,destination为目标字符串,source为要连接的字符串。
下面是一个示例代码:
#include <stdio.h>
#include <string.h>
int main() {
char str1[100] = "Hello";
char str2[] = " World!";
strcat(str1, str2);
printf("连接后的字符串:%s\n", str1);
return 0;
}
在该示例中,str1为目标字符串,str2为要连接的字符串。通过调用strcat函数将str2连接到str1上,最终输出的结果为"Hello World!"。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: c语言字符数组怎么定义和赋值