How can I print 0x0a instead of 0xa using cout?

This works for me in GCC: #include <iostream> #include <iomanip> using namespace std; int main() { cout << “0x” << setfill(‘0′) << setw(2) << right << hex << 10 << endl; } If you are getting sick and tired of iostream’s formatting quirkiness, give Boost.Format a try. It allows good-old-fashioned, printf-style format specifiers, yet it … Read more