문제

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