string c++ ends with code example
Example: c++ endswith
#include <iostream>
using namespace std;
inline bool endsWith(string const &value, string const &ending)
{
if (ending.size() > value.size()) return false;
return equal(ending.rbegin(), ending.rend(), value.rbegin());
}
int main() {
string teststring = "This should return true because the string ends with a period.";
string ending = ".";
cout << endsWith(teststring, ending);
}