cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : ios : fill
- -
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
ios
· ios::ios
· ios::~ios
member functions:
· ios::bad
· ios::clear
· ios::copyfmt
· ios::eof
· ios::exceptions
· ios::fail
· ios::fill
· ios::good
· ios::imbue
· ios::init
· ios::narrow
· ios::operator!
· ios::operator void*
· ios::rdbuf
· ios::rdstate
· ios::setstate
· ios::tie
· ios::widen

-

ios::fill public member function
char fill ( ) const;
char fill ( char fillch );

Get/set the fill character

The first function version returns the fill character.

The second function version sets fillch as the new fill character and returns the fill character previously set.

The fill character is the character used by output insertion functions to fill spaces when padding results to the field width.

The parameterized manipulator setfill can also be used to set the fill character.

Parameters

fillch
the new character to be used as fill character.

Return Value

The value of the fill character before the call.

Example

// using the fill character
#include <iostream>
using namespace std;

int main () {
  char prev;

  cout.width (10);
  cout << 40 << endl;

  prev = cout.fill ('x');
  cout.width (10);
  cout << 40 << endl;

  cout.fill(prev);

  return 0;
}

The output of this example is something similar to:

        40
xxxxxxxx40

Basic template member declaration

( basic_ios<charT,traits> )
typedef charT char_type;
char_type fill () const;
char_type fill ( char_type fillch );

See also

setfill Set fill character (manipulator function)
ios_base::width Get/set field width (public member function)

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