13.7.3. Padding (fill, setfill)

The fill member function specifies the fill character to be used with justified fields; spaces are used for padding by default. The function returns the prior padding character. The setfill manipulator also sets the padding character. Figure 13.16 demonstrates function fill (line 30) and stream manipulator setfill (lines 34 and 37) to set the fill character.

 1   // Fig. 13.16: fig13_16.cpp 2   // Using member function fill and stream manipulator setfill to change 3   // the padding character for fields larger than the printed value. 4   #include <iostream> 5   #include <iomanip> 6   using namespace std; 7  8   int main() 9   {10      int x = 10000;11 12      // display x13      cout ...

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.