cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : manipulators : setfill
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
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
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)

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us