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;
}
#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;
}
温馨提示:答案为网友推荐,仅供参考