Вопрос

In my program I would like to display status messages like so

Checking system               [OK]
Loading required files        [OK]
...

But right now its comes like the following when I use \t

Checking system        [OK]
Loading required files        [OK]

I tried setw but it comes like (probably because of bad implementation)

           Checking system[OK]
    Loading required files[OK]

So is there a way I can format the output WITHOUT using any external libraries (ie, no ncurses etc)

Also note that the size of the output terminal is known.

Это было полезно?

Решение

You can use std::left to display a string left-justified in a specified width of field:

std::cout << std::left << std::setw(30) << "Checking system";
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top