C-StrEnd:文字列tが文字列sの末尾にある場合は1を返し、それ以外の場合は0を返します。

大きな牛の人工知能のチュートリアルを共有します。ゼロベース!わかりやすい!面白くてユーモラス!あなたも人工知能チームに参加してください!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