Should be a trivial question, but found that setw only apply to its immediate following output, and not sure how to allow it apply to all the following output.
For example, for the following line of code
cout<<setw(3)<<setfill('0')<<8<<" "<<9<<endl;
or
cout.width(3);
cout.fill('0');
cout<<8<<" "<<9<<endl;
I want the output to be 008 009
instead of 008 9
setw
isn't sticky, so you have to say it every time:
cout << setfill('0') << setw(3) << 8 << " "
<< setw(3) << 9 << endl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With