Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::left

 

std::left is a stream manipulator to let the minus and the digits of a negative number both be put at the left of the padding width.

 

#include <iomanip>
#include <iostream>

int main ()
{
  const int x = -12;
  std::cout
    << std::setw(4)  << std::internal << x << '\n'
    << std::setw(4)  << std::left     << x << '\n'
    << std::setw(4)  << std::right    << x << '\n';
}

 

Screen output:

 

- 12
-12 
 -12

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict