With printf-family of functions you can simply use %x or %X format specifier!