1

I am planning to organize output strings in double column in terminal console, where setw() is applied to configure the widths of each columns.

I nonetheless find if length of the string, which is to be displayed in the right column, exceeds the pre-configured limit, the residual part will be put on the beginning of the next line. But I want it still at right part.

For example,

std::string a = "Hello World";
std::string b = "Stack Overflow is awesome";
std::cout << std::setw(140) << left << a
          << std::setw(5) << left << b << std::endl;

"Overflow" will be in the left column but I want it to be in right. Output will be: Hello World S tack Overflow

Is there any solution to it? Or I have to write a print function customizing this condition?

Jake0x32
  • 1,402
  • 2
  • 11
  • 18

0 Answers0