C++ iomanip right Manipulator
Example
Print a value in a field that is 6 characters wide, aligned to the left and to the right:
cout << "[" << left << setw(6) << "Hi" << "]\n";
cout << "[" << right << setw(6) << "Hi" << "]";
Definition and Usage
The right manipulator aligns the output to the right, when you use setw(). The empty space is added in front of the value.
This is the default, so you only need right to go back after you have used left.
The right manipulator is defined in the <ios> header file.
Syntax
cout << right;
You do not need to include <iomanip> to use right. 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. |
|---|