Encoders
>
More...
>
C
>
Program
/* Function strend(s,t) which returns 1 if the string t occurs at the end of
the string s, and 0 otherwise. (using pointers) */
#include <stdio.h>
int strend(char *s, char *t);
main()
{
printf("%d\n",strend("hello world","world"));
}
int strend(char *s, char *t)
{
char *start_s=s, *start_t=t;
while(*s)
s++;
while(*t)
t++;
while(*s==*t && s!=start_s && t!=start_t)
s--, t--;
return *s==*t && t==start_t && *t!='\0';
}
|