Is there any way in C++ to check whether a string starts with a certain string (smaller than the original) ? Just like we can do in Java
bigString.startswi
I'm surprised no one has posted this method yet:
#include using namespace std; bool starts_with(const string& smaller_string, const string& bigger_string) { return (smaller_string == bigger_string.substr(0,smaller_string.length())); }