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

   2025-02-13 4410
核心提示:可以使用strcat函数将三个字符串连接起来。#include stdio.h#include string.hint main() {char str1[50] = Hello;char str2[] =

可以使用strcat函数将三个字符串连接起来。

#include <stdio.h>#include <string.h>int main() {    char str1[50] = "Hello";    char str2[] = "C";    char str3[] = "Language";    char result[100];    strcpy(result, str1);    strcat(result, str2);    strcat(result, str3);    printf("Result: %s\n", result);    return 0;}

输出结果为:Result: HelloCLanguage

 
 
更多>同类维修知识
推荐图文
推荐维修知识
点击排行
网站首页  |  关于我们  |  联系方式  |  用户协议  |  隐私政策  |  网站留言