C语言:编写程序,将两个字符串s1和s2连接起来。(求大神解答,麻烦请按提问中的格式回答,谢谢)
main(){chars1[80],s2[80];printf(“\nInputastring:”);gets(s1);printf(“\nInputastring:”)...
main()
{ char s1[80],s2[80];
printf(“\nInput a string:”);
gets(s1);
printf(“\nInput a string:”);
gets(s2);
conj(s1,s2);
puts(s1);
}
conj(char *p1,char *p2)
{
char *p=p1;
while (*p1!='\0')【 】;
while (*p2 !='\0') { *p1=【 】; p1++;p2++;}
*p1='\0';
} 展开
{ char s1[80],s2[80];
printf(“\nInput a string:”);
gets(s1);
printf(“\nInput a string:”);
gets(s2);
conj(s1,s2);
puts(s1);
}
conj(char *p1,char *p2)
{
char *p=p1;
while (*p1!='\0')【 】;
while (*p2 !='\0') { *p1=【 】; p1++;p2++;}
*p1='\0';
} 展开
3个回答
展开全部
#include <stdio.h>
void conj(char *p1, char *p2)
{
while (*p1) p1++;
while (*p2) {*p1 = *p2; p1++; p2++;}
*p1 = 0;
}
void main()
{
char s1[80], s2[80];
printf("\nInput a string: "); gets(s1);
printf("\nInput a string: "); gets(s2);
conj(s1, s2);
puts(s1);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询