Domanda

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.

È stato utile?

Soluzione

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";
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top