setw
[manipulator]
smanip setw ( int n );
<iomanip>
  cplusplus.com  

Set field width
  Sets a value to be used as the field width for the next insertion operation as if a call to stream member width(n).
  The field width determines the minimum number of characters to be written by next insertion operation. If the standard width of the representation is shorter than the field width, the representation is padded with fill characters (setfill).   You must include <iomanip> to use this manipulator.

Parameters.

n
Number of characters to be used as field width.

Return Value.
  Unspecified.
  This function should only be used as a stream manipulator.

Example.

// setw example
#include <iostream>
#include <iomanip>
using namespace std;

int main () {
  cout << setw (10);
  cout << 77 << endl;
  return 0;
}
This code uses setw to set the field width to 10 characters.

See also.
  setfill
  iomanip manipulators


© The C++ Resources Network, 2001