Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
manipulators
boolalpha
dec
endl
ends
fixed
flush
hex
internal
left
noboolalpha
noshowbase
noshowpoint
noshowpos
noskipws
nounitbuf
nouppercase
oct
resetiosflags
right
scientific
setbase
setfill
setiosflags
setprecision
setw
showbase
showpoint
showpos
skipws
unitbuf
uppercase
ws


setfill

manipulator function
<iomanip>
smanip setfill ( char c );

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

1
2
3
4
5
6
7
8
9
10
// 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