Share via


ios::width

int width( int nw );

int width() const;

Return Value

The first overloaded width function sets the stream’s internal field width variable to nw. When the width is 0 (the default), inserters insert only the number of characters necessary to represent the inserted value. When the width is not 0, the inserters pad the field with the stream’s fill character, up to nw. If the unpadded representation of the field is larger than nw, the field is not truncated. Thus, nw is a minimum field width.

The internal width value is reset to 0 after each insertion or extraction.

The second overloaded width function returns the current value of the stream’s width variable.

Parameter

nw

The minimum field width in characters.

ios OverviewAbstract Stream Base Class

See Also   ios setw manipulator