ios_base::width
streamsize width ( ) const;
streamsize width ( streamsize wide );
ios_base
  cplusplus.com  

Get/Set field width.
  The first syntax returns the current value of the field width.
  The second syntax sets a new field width.
  The field width determines the minimum number of characters to be written in some output representations. If the standard width of the representation is shorter than the field width, the representation is padded with fill characters at a point determined by format flag adjustfield (left, right or internal).

  The fill character can be retrieved or modified by calling ios::fill.
  The format flag adjustfield can be modified by calling member functions flags and setf or by inserting manipulators left, right and internal

Parameters.

wide
New value for the stream's field width. This is an integer value of type streamsize.

Return Value.
  The field width of the stream before the call.

Example.

// field width
#include <iostream>
using namespace std;

int main () {
  cout << 100 << endl;
  cout.width(10);
  cout << 100 << endl;
  cout.fill('x');
  cout.width(15);
  cout << left << 100 << endl;
  return 0;
}
The execution of this example shall display something similar to:
100
       100
100xxxxxxxxxxxx

See also.
  flags, setf, ios::fill,
  fmtflags type, ios_base class


© The C++ Resources Network, 2001