Boris
Boris

Reputation: 21

How to align and concatenate parts of string using {fmt}

I want to format 5 strings like:

   int half { 32 };
    string middle { "[===]" };
    string str = fmt::format("{0:<{half}}{1:<}{4}{2:<{half}}{3:<}",
                      "lpad",
                      "left",
                      "rpad",
                      "right",
                      middle,
                      fmt::arg("half", half));
    cout << str << endl;

What I want:

lpadleft                            [===]rpadright

And what I get:

lpad                            left[===]rpad                            right

How can I reach desired? Thanks in advance!

Upvotes: 0

Views: 73

Answers (0)

Related Questions