Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   converting binary file hex values to ascii (http://www.go4expert.com/forums/converting-binary-file-hex-values-ascii-t21835/)

vihrao 19Apr2010 08:45

converting binary file hex values to ascii
 
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 19Apr2010 14:48

Re: converting binary file hex values to ascii
 
%c prints characters. Hex values are done with %x.


All times are GMT +5.5. The time now is 12:45.