Strings In Depth10 / 15
Up next

substr

#include <print>
#include <string>

int main() {
    std::string s = "hello world";
    // substr(pos, len) copies out a piece
    std::println("{}", s.substr(0, 5));
    std::println("{}", s.substr(6));
}
What you're solving

copy a range of characters