setw

"Permanent" std::setw

Hi, is there any way how to set std::setw manipulator (or its function 'width') permanently? Look at this: #include <iostream> #include <iomanip> #include <algorithm> #include <iterator> int main( void ) { int array[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256 }; std::cout.fill( '0' ); std::cout.flags( std::ios::hex ); std::cout.wid...

Displaying text in correct column

After getting a helpful answer here, I have run into yet another problem: displaying two or more strings in the column I want it to be displayed in. For an example of the problem I have, I want this output: Come here! where? not here! but instead get Come here! where? not here! when I use the code c...

Truncate C++ string fields generated by ostringstream, iomanip:setw

In C++ I need string representations of integers with leading zeroes, where the representation has 8 digits and no more than 8 digits, truncating digits on the right side if necessary. I thought I could do this using just ostringstream and iomanip.setw(), like this: int num_1 = 3000; ostringstream out_target; out_target << setw(8) << ...

Setw and setfill equivalent in BASH

Hi, Could you please tell me what the equivalent BASH code for the following C++ snippet would be: std::cout << std::setfill('x') << std::setw(7) << 250; The output is: xxxx250 Thanks for the help! ...