fill.cpp

When console output is smaller than the specified output field width, the output is filled or padded. The default fill character is a blank or space. The setfill function changes the fill character, and once the fill character is changed, it is used fill operations until it is changed with another call to setfill.

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	cout << "|" << setw(20) << 123.45 << "|" << endl;

	cout << endl;

	cout << "|" << setfill('0') << setw(20) << 123.45 << "|" << endl;
	cout << "|" << left << setw(20) << 123.45 << "|" << endl;
	cout << "|" << right << setw(20) << 123.45 << "|" << endl;

	cout << endl;

	cout << "|" << setw(20) << 123.45 << "|" << endl;

	cout << endl;

	cout << setfill(' ') << "|" << setw(20) << 123.45 << "|" << endl;

	return 0;
}

Output:

|              123.45|

|00000000000000123.45|
|123.4500000000000000|
|00000000000000123.45|

|00000000000000123.45|

|              123.45|