#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int strend(char *s, char *t)
{
int step = strlen(s) - strlen(t);
char *pos = s + step;
while(*pos++ == *t++)
{
if(*pos == '\0')
return 1;
}
return 0;
}
int main()
{
char *s = "sklfjl";
char *t = "jl";
printf("%d\n", strend(s,t));
return 0;
}
练5-4 习编写strend(s,t)函数。如果字符串t出现在字符串s的尾部,该函数返回1,否则返回0。
最新推荐文章于 2023-05-25 14:27:41 发布