Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <string.h> // strlen(), memcmp()
  2.  
  3. int strend(const char *s, const char *t)
  4. {
  5. size_t ls = strlen(s); // find length of s
  6. size_t lt = strlen(t); // find length of t
  7. if (ls >= lt) // check if t can fit in s
  8. {
  9. // point s to where t should start and compare the strings from there
  10. return (0 == memcmp(t, s + (ls - lt), lt));
  11. }
  12. return 0; // t was longer than s
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement