c++ - inconsistent behavior of <iomanip> -
i have following code
cout << setfill('0') << setw(4) << hex << 100 << 100 << std::endl;
the output is:
006464
if want let every number width 4, have use
out << setfill('0') << setw(4) << hex << 100 << sew(4) << 100 << std::endl;
but if want print every number hex , setfill('0'), need set setfill('0') , std::hex once.
does c++ design on purpose? intention?
yes on purpose. stream operations internally peppered resets of field width, specified standard. think there's no answer why.
Comments
Post a Comment