width [C++ Reference]
Keywords: io,width
Date: 2009-03-09T12:24:57-0700

[[width]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## width

Syntax:

        int ostream::width();
        int ostream::width(int w);

The function width() returns the current width, which is defined as the minimum number of characters to display with the next output. The optional argument w can be used to set the width. For example:

         cout.width( 5 );
         cout << "2";

displays

        2

(that's four spaces followed by a '2')

Related Topics: fill, precision

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •