How can I use substring to print an ID number that is read from an input file to print out as for example, *--4554 instead of 455454554? I was thinking of using modulus but it is too complex

Would something like the following fit the requirements?

    std::string str = "455454554";
    std::cout << "*-" << str.substr(str.size() - 4, std::string::npos) << std::endl;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.