Hacker News new | ask | show | jobs
by AdieuToLogic 3596 days 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;