for(int i =0 ; i < 4; i++)
{
std::cout<<std::setw(5)<<' '<<std::setw(16)<<fsu::HexFill<<number<<std::endl;
}
The blank lines are also getting filled with 0 . I am sure its because the stream is set to fill with (0). How can I make the manipulator HexFill display zeroes only for the number and not the blank lines ?
Well, your options are limited for manipulators. You want it to work the way std::setw does, but std::setw calls ios::width, and the width is reset to 0 on insertion or extraction from a stream. There is no corresponding functionality for ios::fill.
Perhaps another manipulator (fsu::BlankFill, maybe) could be used to reset the fill characters, making the code look like:
1 2
for ( int i = 0; i<4; ++i )
std::cout << std::setw(5) << fsu::BlankFill << ' ' << std::setw(16) << fsu::HexFill << i << std::endl;
Or supply the width with the fill manipulator to make things a little more compact:
1 2
for ( int i = 0; i<4; ++i )
std::cout << fsu::BlankFill(5) << ' ' << fsu::HexFill(16) << i << std::endl;
Of course, you could always just save and restore state on each iteration of the for loop.
okay thanks a lot I will do it with fsu::BlankFill . hahah yeah custom oops its not like the manipulators are dressing as batman for a Halloween party .