请别写函数fun,该函数的功能是:将放在字符串数组中的M个字符串(每串的长度不超过N),按顺序合并组成一个新的字符串

/请别写函数fun,该函数的功能是:将放在字符串数组中的M个字符串(每串的长度不超过N),按顺序合并组成一个新的字符串/

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

#define M 5 
#define N 10 

int main()
{
    char strings[M][N] = {"Hello", "World", "of", "Programming", "inC"};
    char result[N * M + 1];
    int i, j, result_index = 0;
    for (i = 0; i < M; i++)
    {
        for (j = 0; j < strlen(strings[i]); j++)
        {
            result[result_index++] = strings[i][j];
        }
    }
    result[result_index] = '\0';
    printf("Merged string: %s\n", result);
    return 0;
}

posted on 2024-06-28 23:44  wessf  阅读(17)  评论(0)    收藏  举报