To set the width of the output field.
smanip<int> setw(int)
Use the manipulator setw() directly in a stream to set the field size for output. A pointer to ostream is returned.
ios_base::width()
#include <iostream> #include <iomanip> int main() { using namespace std; cout << setw(8) << setfill('*') << "Hi!" << endl; return 0; }
Result:
Hi!*****