I have output that looks like this:
BTC-USDT [FTX] 20460.91 20470.09
BTC-USDT [BINANCE_US] 20457.34 20467.28
BTC-USDT [BINANCE_US] 20457.50 20467.28
I would like it to look like this:
BTC-USDT [ FTX] 20460.91 20470.09
BTC-USDT [BINANCE_US] 20457.34 20467.28
BTC-USDT [BINANCE_US] 20457.50 20467.28
I think I am close with this code, but I am confused by setw()
std::cout << pair << std::setfill(' ') << std::setw(15) << " [" << exch << "] " << fixed << setprecision(2) << bid << " " << ask << std::endl;
If you want a given value to have certain output characteristics, like width, alignment, etc, you need to apply the appropriate I/O manipulator(s) before you output the value, not after.
In your example, you want
pairto be left-aligned with a width of 9, andexchto be right-aligned with a with of 10, so applystd::setwandstd::left/std::rightaccordingly, eg:Output:
Online Demo