take pieces of a string in c++

#include <iostream>
#include <string>

int main() {
    std::string fullString = "This is a sample string";

    // Extract substring from index 0 to 3 (excluding 3)
    std::string substring1 = fullString.substr(0, 3);
    std::cout << "Substring 1: " << substring1 << std::endl;

    // Extract substring from index 5 to the end of the string
    std::string substring2 = fullString.substr(5);
    std::cout << "Substring 2: " << substring2 << std::endl;

    // Find the position of the word "sample" in the string
    size_t position = fullString.find("sample");

    // Extract substring starting from the position of "sample"
    std::string substring3 = fullString.substr(position);
    std::cout << "Substring 3: " << substring3 << std::endl;

    return 0;
}