SDUT OJ串结构练习——字符串连接

串结构练习——字符串连接

Time Limit: 1000 ms Memory Limit: 65536 KiB

Submit Statistic Discuss

Problem Description

 给定两个字符串string1和string2,将字符串string2连接在string1的后面,并将连接后的字符串输出。

连接后字符串长度不超过110。 

Input

 输入包含多组数据,每组测试数据包含两行,第一行代表string1,第二行代表string2。

Output

 对于每组输入数据,对应输出连接后的字符串,每组输出占一行。

Sample Input

123
654
abs
sfg

Sample Output

123654
abssfg

Hint

Source

赵利强

 #include<stdio.h>
 #include<string.h>
 int main()
 {
   char str1[110],str2[110];
   while(gets(str1)!=NULL)
   {
     gets(str2);
     strcat(str1,str2);
     puts(str1);
   }
return 0;
 }
///主要用到strcat函数
///区别:strcat函数用于字符串的连接,strcpy用于字符串的复制,后一个字符串将前一个字符串覆盖

猜你喜欢

转载自blog.csdn.net/qq_41374539/article/details/81166604