std::setw (3) - Linux Manuals
std::setw: std::setw
NAME
Synopsis
Defined in header <iomanip>
/*unspecified*/ setw( int n );
When used in an expression out << setw(n) or in >> setw(n), sets the width parameter of the stream out or in to exactly n.
Parameters
n - new value for width
Return value
Returns an object of unspecified type such that if str is the name of an output stream of type std::basic_ostream<CharT, Traits> or std::basic_istream<CharT, Traits>, then the expression str << setw(n) or str >> setw(n) behaves as if the following code was executed:
str.width(n);
Notes
The width property of the stream will be reset to zero (meaning "unspecified") if any of the following functions are called:
* Input
* Output
The exact effects this modifier has on the input and output vary between the individual I/O functions and are described at each operator<< and operator>> overload page individually.
Example
// Run this code
Output:
See also
width (public member function of std::ios_base)
setfill (function template)
internal sets the placement of fill characters
left (function)
right