Many compilers support the itoa function (which appears in the POSIX standard, but not in the C or C ++ standards). Visual C ++ calls it _itoa .
#include <stdlib.h> char hexString[20]; itoa(value, hexString, 16);
Note that there is no such thing as a decimal value or a hexadecimal value. Numeric values ββare always stored in binary format. Only the string representation of a number has a specific base (base).
Of course, using the %x format specifier with any of the printf functions is good when the value should be displayed in a longer message.
source share