Write data in columns
This sample is licensed under the CC0 Public Domain Dedication.
Align data in columns when writing to an output stream.
We use I/O manipulators to align the data in columns. The
std::setw manipulator sets the
width of a column, while
std::right set the alignment of the
written value within that column. For example, on line 6, we
write the name “John Smith” to a column of width 12 and align
it to the left of the column.