//strcat实现
char* _strcat(char *s, char *t)
{
char *address = s;
assert(s != NULL && t != NULL);
while (*address)
{
++address;
}
while(*address++ = *t++)
;
return address;
}
//t是否在s尾部出现
int strlend(char *s, char *t)
{
int sLength = strlen(s);
int tLength = strlen(t);
if(sLength < tLength)
return 0;
if(!tLength) return 1;
return !strcmp(&s[sLength - tLength], t);
}
本文深入探讨了C语言中用于字符串操作的两个关键函数:_strcat和strlend。首先,我们通过具体代码实例详细解释了_strcat函数如何实现字符串连接,并讨论了其使用注意事项。接着,strlend函数的作用被揭示,它能够判断目标字符串s的尾部是否完全包含另一个字符串t。文章最后总结了这两个函数在实际编程中的应用,强调了它们在处理字符串时的高效性和灵活性。

被折叠的 条评论
为什么被折叠?



