一个 c语言题目

3.从键盘输入3 个字符串(每个字符串以回车符做为结束标志),将3个字符串以输入先后顺序合并到字符串s中,请填空使用程序完整。
【例如输入:123
abc
456
则输出123abc456】

#include "stdio.h"
#include "string.h"
main()
{
char s[100]="";
/*可以写多行代码*/
printf("%s", s);
}

#include "stdio.h"
#include "string.h"

int main()
{
    char s[100]="";
    /*可以写多行代码*/
    int  i = 0, n = 3;
    char ch;
    while(n--)
    {
        while(1)
        {
            if( (ch=getchar()) == '\n')
                break;
            else            
                s[i++] = ch;
        }
    }
    s[i] = '\0';
    
    printf("%s", s);
    return 0;
}
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网