How can I format text "justified" so it aligns to the left and right side for a given width?
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.");
}
Expected output:
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 simple example how to solve this problem is this:
It works like this: