strendswith.c 310 B

123456789101112
  1. #include <api.h>
  2. bool strendswith(const char* haystack, const char* needle) {
  3. size_t haystack_len = strlen(haystack);
  4. size_t needle_len = strlen(needle);
  5. if (haystack_len < needle_len) {
  6. return false;
  7. }
  8. return !memcmp(&haystack[haystack_len - needle_len], needle, needle_len);
  9. }