string substr (size_t pos, size_t len) const;
std::string str = "Hello, world!"; std::string substr = str.substr(7, 5); // substr -> "world"
std::string str = "http://www.example.com"; std::string prefix = "http://"; std::string withoutPrefix = str.substr(prefix.length()); // withoutPrefix -> "www.example.com"In this example, we are creating a new string `withoutPrefix` that starts at the end of the `prefix` string and has the same length as the remaining part of `str`. This function is part of the C++ Standard Library.