I need to display three values which is parsed from packet binary data(0x123400005678).
unsigned int k = 0x1234, l=0x0, m=0x5678;
I can display with four-digit hex value when I use cout three times.
#include <iostream>
#include <iomanip>
...
cout << "seperated cout" << endl;
cout << hex << setfill ('0') << setw (4) << k;
cout << hex << setfill ('0') << setw (4) << l;
cout << hex << setfill ('0') << setw (4) << m << endl;
....
seperated cout
123400005678
But when I use only one cout line, leading zero of '0x0' is omitted...
#include <iostream>
#include <iomanip>
...
cout << "oneline cout" << endl;
cout << hex << setfill ('0') << setw (4) << k << l << m << endl;
...
oneline cout
123405678
Is there anyway to display like '123400005678' with one line cout? Or is using cout three times only way to do this?
Thank you in advance.