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
With C++20 you can use std::basic_string::starts_with (or std::basic_string_view::starts_with):
#include
std::string_view bigString_v("Winter is gone"); // std::string_view avoids the copy in substr below.
std::string_view smallString_v("Winter");
if (bigString_v.starts_with(smallString_v))
{
std::cout << "Westeros" << bigString_v.substr(smallString_v.size());
}