输入两个字符串,输出连接后的字符串。要求自定义函数char * strcat

发布网友

我来回答

1个回答

热心网友

question4:
//Do not change the original value of the variable
char *strcat(char *s,char *t)
{
char *point = s;

int lengh = 0;
static char *tarStr = NULL;

lengh = length(s) + lengh(t) + 1;

tarStr = molloc(sizeof(char) * lengh);

while(1)

{
if(*point != '\0')

{

tarStr[i] = *point;

i++;

point++;

}

else

{
point = t;

}

if(i >= lengh)

break;

}
return tarStr;

}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com