acidzombie24 acidzombie24 - 26 days ago 7
C++ Question

c++ cout hex values?

I want to do:

int a = 255;
cout << a;


and have it show FF in the output, how would i do this?

Answer

Use:

#include <iomanip>

...

std::cout << std::hex << a;

There are many other options to control the exact formatting of the output number, such as leading zeros and upper/lower case.