setfill | manipulator function |
smanip setfill ( char c ); |
<iomanip> |
Set fill character
Sets the fill character to the value of parameter c.
Behaves as if a call to the stream's member ios::fill with c as argument was made.
The fill character is used in output insertion operations to fill spaces when results have to be padded to the field width.
This manipulator is declared in header <iomanip>, along with the other parameterized manipulators: resetiosflags, setiosflags, setbase, setprecision and setw. This header file declares the implementation-specific smanip type, plus any additional operator overload function needed to allow these manipulators to be inserted and extracted to/from streams with their parameters.
Parameters
- c
- Character to be used as fill character.
Return Value
Unspecified. This function should only be used as a stream manipulator.Example
// setfill example #include <iostream> #include <iomanip> using namespace std; int main () { cout << setfill ('x') << setw (10); cout << 77 << endl; return 0; } |
This code uses setfill to set the fill character to 'x'. The output of this example is something similar to:
xxxxxxxx77 |
See also
setw | Set field width (manipulator function) |
ios::fill | Get/set the fill character (public member function) |