converting binary file hex values to ascii

vihrao's Avatar, Join Date: Apr 2010
Newbie Member
I am able to read binary file and print bytes. When I print using %d format it prints decimal value. When I use %c format it prints junk.
As an example the binary file looks like this: A9D1CA....
As I print each unsigned char byte with %d format I get values like: 169, 209, 203 and so forth. These are decimal valuees. If I print it with %c format then I get junk on the screen.
How can I print this the Hex values in ascii on the console?
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
%c prints characters. Hex values are done with %x.