4 ms·
to see if a string starts with another string in C++ As others have pointed out, while a person could use std::mismatch C++'s std::basic_string type has a
by AdieuToLogic 10y ago
to see if a string starts with another string in C++
As others have pointed out, while a person could use
std::mismatch
C++'s std::basic_string type has a compare method. So, the Go example you presented:
strings.HasPrefix(toCheck, prefix)
Could be expressed in Standard C++ as:
toCheck.compare (0, prefix.length (), prefix) == 0;