C++ iomanip left Manipulator
Example
Print a value in a field that is 6 characters wide, aligned to the right (default) and to the left:
cout << "[" << setw(6) << "Hi" << "]\n";
cout << "[" << left << setw(6) << "Hi" << "]";
Definition and Usage
The left manipulator aligns the output to the left, when you use setw(). The empty space is added after the value, instead of in front of it.
left keeps working for all the values printed after it, until you use right.
The left manipulator is defined in the <ios> header file.
Syntax
cout << left;
You do not need to include <iomanip> to use left. It is available when you include <iostream>.
Parameter Values
None.
Technical Details
| Returns: | A reference to the stream (you do not use it directly). It changes all the values printed after it. |
|---|