Using various padding characters : int display « Data Types « C++ Tutorial






#include <iostream>
#include <iomanip>

using std::cout;
using std::endl;
using std::ios;
using std::setw;
using std::hex;
using std::dec;
using std::setfill;

int main()
{
   int x = 10000;

   cout.setf( ios::right, ios::adjustfield );
   cout.fill( '*' );
   cout << setw( 10 ) << dec << x << '\n';
   cout.setf( ios::left, ios::adjustfield );
   cout << setw( 10 ) << setfill( '%' ) << x << '\n';
   cout.setf( ios::internal, ios::adjustfield );
   cout << setw( 10 ) << setfill( '^' ) << hex << x << endl;
   return 0;
}








2.5.int display
2.5.1.Displaying Leading Zeros
2.5.2.Change width as you output
2.5.3.setiosflags(ios::left) and resetiosflags(ios::left)
2.5.4.Line up columns of data with cout.width
2.5.5.Using various padding characters
2.5.6.Output decimal to hexadecimal, octal and align the output
2.5.7.Set cout for hex number output