This code prints:Code:#include <iostream> #include <iomanip> #include <string> using namespace std; main () { cout << hex << setw(2) << setfill('0') << 0x00 << endl; cout << hex << setw(2) << setfill('0') << 0x07 << endl; cout << hex << setw(2) << setfill('0') << 0xFF << endl; }
00
07
ff
Try using setw and setfill instead of setprecision.




Reply With Quote