在C语言中,可以使用字符串拼接函数strcat来在字符串后面追加一个字符串。具体用法如下:

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

int main() {
    char str1[20] = "Hello";
    char str2[10] = "World";

    strcat(str1, str2);

    printf("拼接后的字符串为:%s\n", str1);

    return 0;
}

输出结果为:

拼接后的字符串为:HelloWorld

在上面的代码中,我们使用strcat函数将str2追加到str1的末尾,并将结果存储在str1中。需要注意的是,str1必须具有足够的空间来容纳追加后的字符串,否则会导致内存溢出。

C语言在字符串后面追加一个字符串

原文地址: https://www.cveoy.top/t/topic/bqpT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录