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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -