C - StrEnd: Return 1 if the string t occurs at the end of the string s, and zero otherwise

分享一个大牛的人工智能教程。零基础!通俗易懂!风趣幽默!希望你也加入到人工智能的队伍中来!请点击http://www.captainbed.net

/*
 * StrEnd: Return 1 if the string t occurs at the end of the string s,
 * and zero otherwise.
 *
 * StrEnd.c - by FreeMan
 */

int StrLen(const char *s)
{
	char *p = s;
	while (*p != '\0')
	{
		p++;
	}
	return p - s;
}

int StrEnd(const char *s, const char *t)
{
	s += StrLen(s) - StrLen(t);
	while (*s && *s++ == *t++);
	return !*s;
}

猜你喜欢

转载自blog.csdn.net/chimomo/article/details/114590235
今日推荐