C语言编程字符串连接问题

来源:百度知道 编辑:UC知道 时间:2024/06/18 06:17:00
编写一个函数StrCatenate,输入两个字符串,将第二个字符串与第一个字符串连接,连接后的结果由第一个字符串返回!

谢谢了 帮帮我
最好简单些 我是新手 谢谢 有加分

char * StrCatenate(char *p1,char *p2)
{ while(*p1!='\0")
{ p1++;}
while(*p2!='\0')
{ *p1++=*p2++;}
*p2='\0';
return p1;
}
#include "stdio.h"
main()
{ char *p1;
char *p2;
gets(p1);
gets(p2);
p1=StrCatenate(p1,p2);
puts(p1);
}

在给你写个数组型的吧`
`
viod StrCatenate(char s1[],char s2[])
{ int i=0,j=0;

while(s1[i]!='\0')
i++;
while(s2[j]!='\0')
{s1[i]=s2[j];
i++;
j++;
}
s1[i]='\0';
}

#include"stdio.h"
#include"string.h"
char *StrCatenate()
{
char m[10000],n[100];
printf("输入两个字符串:\t");
gets(m);
printf(" \t");
gets(n);
return(strcat(m,n));
}
void main()
{
p