温馨提示×

c语言怎么把三个字符串连起来

小亿
283
2024-03-15 16:38:54
栏目: 编程语言
C语言开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

可以使用strcat函数将三个字符串连接在一起,示例如下:

#include <stdio.h>
#include <string.h>

int main() {
    char str1[50] = "Hello, ";
    char str2[] = "world";
    char str3[] = "!";
    
    strcat(str1, str2);
    strcat(str1, str3);
    
    printf("%s\n", str1);
    
    return 0;
}

输出结果为:

Hello, world!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:c语言如何把三个字符串连起来

0