Deity.342
2022-05-20 21:37
采纳率: 88.9%
浏览 30

如何将十个字符串连在一起啊


#include<stdio.h>
int main()
{
    char s1[10], s2[10], s3[10], s4[10], s5[10], s6[10], s7[10], s8[10], s9[10], s10[10];
    scanf("%s", &s1);
    scanf("%s", &s2);
    scanf("%s", &s3);
    scanf("%s", &s4);
    scanf("%s", &s5);
    scanf("%s", &s6);
    scanf("%s", &s7);
    scanf("%s", &s8);
    scanf("%s", &s9);
    scanf("%s", &s10);
    int i = 0;
    int j = 0;
    char *str;
    char a[100];  
    str = &s1[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }
    str = &s2[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }
    str = &s3[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s4[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s5[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s6[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s7[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s8[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s9[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    str = &s10[0];
    while(*str != '\0')
    {
        a[i] = *str;
        i++;
        str++;
    }    
    a[i] = '\0';   
    printf("%s\n", a);  
    return 0;
}
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题