怎样将两个string类型的变量连接在一起

sorry 是c语言

第1个回答  推荐于2016-02-24
1、js
<script type="text/javascript">
var a = "我是第一个字符串!!!";
var b = "我是第二个字符串!!!";
var c = a + b;
alert(c);
</script>
2、java
String str1 = "不要啊,不要啊!";
String str2 = “住手啊,住手啊!";
String str = str1 + str2;
System.out.println(str);
3、c
#include <stdio.h>
int main()
{
char s1[80],s2[40];
int i=0,j=0;
printf("\nInput the first string:");
scanf("%s",s1);
printf("\nInput the second string:");
scanf("%s",s2);
while (s1[i] !='\0')
i++;
while (s2[j] !='\0')
s1[i++]=s2[j++]; /* 拼接字符到s1 */
s1[i] ='\0';
printf("\nNew string: %s",s1);
}
相似回答