iomanip setfill() function in C++ with Examples Last Updated : 22 Jul, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The setfill() method of iomanip library in C++ is used to set the ios library fill character based on the character specified as the parameter to this method. Syntax: setfill(char c) Parameters: This method accepts c as a parameter which is the character argument corresponding to which the fill is to be set. Return Value: This method does not returns anything. It only acts as stream manipulators. Example 1: CPP // C++ code to demonstrate // the working of setfill() function #include <iomanip> #include <ios> #include <iostream> using namespace std; int main() { // Initializing the integer int num = 50; cout << "Before setting the fill char: \n" << setw(10); cout << num << endl; // Using setfill() cout << "Setting the fill char" << " setfill to *: \n" << setfill('*') << setw(10); cout << num << endl; return 0; } Output: Before setting the fill char: 50 Setting the fill char setfill to *: ********50 Example 2: CPP // C++ code to demonstrate // the working of setfill() function #include <iomanip> #include <ios> #include <iostream> using namespace std; int main() { // Initializing the integer int num = 50; cout << "Before setting the fill char: \n" << setw(10); cout << num << endl; cout << "Setting the fill" << " char setfill to $: \n" << setfill('$') << setw(10); cout << num << endl; return 0; } Output: Before setting the fill char: 50 Setting the fill char setfill to $: $$$$$$$$50 Reference: http://www.cplusplus.com/reference/iomanip/setfill/ Comment More infoAdvertise with us Next Article fill() function in C++ STL with examples G guptayashgupta53 Follow Improve Article Tags : C++ cpp-input-output CPP-Functions cpp-manipulators Practice Tags : CPP Similar Reads iomanip setbase() function in C++ with Examples The setbase() method of iomanip library in C++ is used to set the ios library basefield flag based on the argument specified as the parameter to this method. Syntax: setbase (int base) Parameters: This method accepts base as a parameter which is the integer argument corresponding to which the base i 2 min read iomanip setprecision() function in C++ with Examples The setprecision() method of iomanip library in C++ is used to set the ios library floating point precision based on the precision specified as the parameter to this method. Syntax: setprecision(int n) Parameters: This method accepts n as a parameter which is the integer argument corresponding to wh 2 min read setw() function in C++ with Examples The setw() method of iomanip library in C++ is used to set the ios library field width based on the width specified as the parameter to this method. The setw() stands for set width and it works for both the input and the output streams.Syntaxsetw(int n);Parameters:n: It is the integer argument corre 2 min read fill_n() function in C++ STL with examples The fill_n() function in C++ STL is used to fill some default values in a container. The fill_n() function is used to fill values upto first n positions from a starting position. It accepts an iterator begin and the number of positions n as arguments and fills the first n position starting from the 2 min read fill() function in C++ STL with examples The fill() function in C++ STL is used to fill some default value in a container. The fill() function can also be used to fill values in a range in the container. It accepts two iterators begin and end and fills a value in the container starting from position pointed by begin and just before the pos 2 min read ios clear() function in C++ with Examples The clear() method of ios class in C++ is used to change the current state of the specified flag by setting it. Hence this function changes the internal state of this stream. Syntax: void clear(iostate state) Parameters: This method accepts the iostate as parameter which is the flag bit to be set in 2 min read Like