Strings In Depth6 / 15
Up next

Compare strings

#include <print>
#include <string>

int main() {
    std::string s = "rust";
    // == compares against another string or a literal
    std::println("{}", s == "rust");
    // starts_with / ends_with arrived in C++20
    std::println("{}", s.starts_with("ru"));
}
What you're solving

== and starts_with