So drucken Sie mit modernem C ++ „justierten“ Text in der Konsole

Wie kann ich Text "ausgerichtet" formatieren, damit er für eine bestimmte Breite links und rechts ausgerichtet wird?

int main()
{
    printJustified("A long text with many words. "
        "A long text with many words. "
        "A long text with many words. "
        "A long text with many words. "
        "A long text with many words.");
}

Erwartete Ausgabe:

A  long text with many words. A long text with
many  words.  A  long  text with many words. A
long text with many words.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage