Skip to content

Latest commit

 

History

History
66 lines (37 loc) · 1.22 KB

CppStdSetw.md

File metadata and controls

66 lines (37 loc) · 1.22 KB

 

 

 

 

 

 

std::setw (an abbreviation of 'set width') is an STL std::iostream manipulator to set the width of the next output.

 


#include <iomanip> #include <iostream> int main() {   const int value = 123;   std::cout     << "12345678\n"     << std::setw(8) << value << '\n'     << std::setfill('x') << std::setw(8) << value << '\n'; }

 

Screen output:

 


12345678      123 xxxxx123

 

 

 

 

 

External links