Exercise 5.4. Write the function strend(s,t), which returns 1 if the string t occurs at the end of the string s, and zero otherwise.
/* strend */
int strend(char *s, char *t)
{
char tmps = *s;
char tmpt = *t;
while(*s)
s++;
while(*t)
t++;
while(*s == *t)
{
if(*s == tmps || *t == tmpt)
break;
s--;
t--;
}
if(*s == *t && *t == tmpt && *s != '\0')
return 1;
else
return 0;
}
Комментариев нет:
Отправить комментарий