Answers for "c++ check that const char* has suffix"

C++
0

c++ check that const char* has suffix

#include <boost/algorithm/string/predicate.hpp>

// works with const char* 
assert(boost::algorithm::ends_with("mystring", "ing"));

// also works with std::string
std::string haystack("mystring");
std::string needle("ing");
assert(boost::algorithm::ends_with(haystack, needle));

std::string haystack2("ng");
assert(! boost::algorithm::ends_with(haystack2, needle));
Posted by: Guest on November-11-2020

Browse Popular Code Answers by Language