1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

converting binary file hex values to ascii

Discussion in 'C' started by vihrao, Apr 19, 2010.

  1. vihrao

    vihrao New Member

    Joined:
    Apr 19, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    %c prints characters. Hex values are done with %x.
     

Share This Page