c语言

c语言如何把两个字符串连接起来

小亿
107
2024-04-11 14:38:00
栏目: 编程语言
C语言开发专用服务器,限时0元免费领! 查看>>

在C语言中,可以使用strcat()函数将两个字符串连接起来。例如:

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

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

运行上面的代码,输出将会是:

Concatenated string: Hello, world!

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

相关推荐:c++怎么将两个字符串连接起来

0
看了该问题的人还看了