I have the following code
int main()
{
std::ostringstream v1,v2;
v1<<setw(5)<<setfill('x')<<5;
v1<<6;
std::cout<<"Version 1: "<<v1.str()<<std::endl;
v2<<setw(5)<<setfill('x')<<5;
v2<<setw(5)<<setfill('x')<<6;
std::cout<<"Version 2: "<<v2.str()<<std::endl;
return 0;
}
In version 1, i have set the manipulator first time. But the when printing 6, it was not filled with 'x'.
In version 2, i have set the manipulator both time. But the when printing 6, it was filled with 'x'.
Whether manipulator has to be set every time (or) am i missing anything here?