13.7.2. Justification (left, right and internal)

Stream manipulators left and right enable fields to be left justified with padding characters to the right or right justified with padding characters to the left, respectively. The padding character is specified by the fill member function or the setfill parameterized stream manipulator (which we discuss in Section 13.7.3). Figure 13.14 uses the setw, left and right manipulators to left justify and right justify integer data in a field.

 1   // Fig. 13.14: fig13_14.cpp 2   // Left and right justification with stream manipulators left and right. 3   #include <iostream> 4   #include <iomanip> 5   using namespace std; 6  7   int main() 8   { 9      int x = 12345;10

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.