c 2b 2b check that const char 2a has suffix

Solutions on MaxInterview for c 2b 2b check that const char 2a has suffix by the best coders in the world

showing results for - "c 2b 2b check that const char 2a has suffix"
Florencia
23 Aug 2018
1#include <boost/algorithm/string/predicate.hpp>
2
3// works with const char* 
4assert(boost::algorithm::ends_with("mystring", "ing"));
5
6// also works with std::string
7std::string haystack("mystring");
8std::string needle("ing");
9assert(boost::algorithm::ends_with(haystack, needle));
10
11std::string haystack2("ng");
12assert(! boost::algorithm::ends_with(haystack2, needle));
13