As you cannot use printf the only solution is to convert the decimal equivalent of the number into the HEX and save it to the file.