Last active
February 1, 2017 20:33
-
-
Save bentrevett/dbcd32e28952f4857b77c5c6970e9c3c to your computer and use it in GitHub Desktop.
Returns true if the string t occurs at the end of the string s, and false otherwise.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdbool.h> | |
bool strend(const char *s, const char *t) | |
{ | |
size_t slen = strlen(s); | |
size_t tlen = strlen(t); | |
if (tlen > slen) return false; | |
else return !strcmp(s + (slen - tlen), t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment