iomanip - STL C++

setfill()

Declaration

(unspecified) setfill(C xFillChar);

Description

This is the setfill() function for output stream manipulation. The argument xFillChar sets the character that is used to fill the extra spaces for numerical output.

Header Include

#include <iomanip>

Example

#include <iostream>
#include <iomanip>

int main() {
	using namespace std;

	double dPi = 3.14159;
	// Output the value with default fill settings
	cout << "Default: " << setw(10) << dPi << endl;

	// Output the value with a different fill
	cout << setfill('_');
	cout << "Using _: " << setw(10) << dPi << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

setfill() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.