您的位置:首页 > 其它

将两个字符串连接起来,不要用strcat

2017-09-23 10:46 225 查看
#include <stdio.h>

int main()
{
char s1[80], s2[40];
int i = 0, j = 0;
printf("\ninput string1:");
scanf("%s", s1);
printf("\ninput string2:");
scanf("%s", s2);
while(s1[i] != '\0')
i++;
while(s2[j] != '\0')
s1[i++] = s2[j++];
s1[i] = '\0';
printf("The new string is:%s\n", s1);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: