输入
三对字符串,每对字符串占一行,用空格隔开。每个字符串只包含数字和英文字母大小写且长度不超过100。
输出
将后一个字符串连接到前一个字符串后面,如果结果字符串长度超过100,输出一行“Result String is cutted.”否则将结果字符串输出来。
样例输入
hello dotcpp 123 456 doyour best
样例输出
hellodotcpp 123456 doyourbest
这题我们可以用strcat函数直接进行拼接,代码如下
#include <stdio.h>
#include <string.h>
int main()
{
char a[100];
char b[100];
while(~scanf("%s %s", a, b)) //循环输入
{
if(strlen(a)+strlen(b)>100) //如果大于100
{
printf("Result String is cutted.\n");
}
else
{
strcat(a,b); //把b字符串拼接到a字符串
printf("%s\n",a);
}
}
}