setw

To set the width of the output field.

smanip<int> setw(int)

Remarks

Use the manipulator setw() directly in a stream to set the field size for output. A pointer to ostream is returned.

See Also

ios_base::width()

Listing: Example of setw() usage:
#include <iostream>
#include <iomanip>

int main()
{
using namespace std;
   cout << setw(8) 
      << setfill('*')
      << "Hi!" << endl;
   return 0;
}

Result:

  Hi!*****