[Solved] How to print string containing numbers right-aligned? [closed]


Find longest string:

        ofstream myfile;
        std::istringstream f("line1\nline2\nline3");
        std::string line;   
        std::string longest = "";
        while (std::getline(f, line)) {
                std::cout << line << std::endl;
                if(line.length() > longest.length()){
                longest = line;
                }
        }

myfile << << std::right << setw(longest.length()) << "Your Text";

This is my solution

2

solved How to print string containing numbers right-aligned? [closed]