Trouble reading a hex value, displaying via printf and writing to a file

This is a discussion on Trouble reading a hex value, displaying via printf and writing to a file within the C Programming forums, part of the General Programming Boards category; I'm trying to read a file that has hex values. I fread into a buffer, but I'm have trouble displaying ...

  1. #1
    MMC
    MMC is offline
    Registered User
    Join Date
    Apr 2002
    Posts
    11

    Trouble reading a hex value, displaying via printf and writing to a file

    I'm trying to read a file that has hex values. I fread into a buffer, but I'm have trouble displaying the values via printf. Also, when I try to write the buffer, I'm getting one 0.

    Any suggestions on how to display a hex value and/or write a hex value to a file, would be appreciated.

    Thanks
    MMC

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    A can be displayed in hex notation by

    printf ("%X", value);

    I don't know exactly what you mean by writing a hex value to a file. But perhaps you mean

    fprintf (file, "%X", value);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IF CONDITION plese help
    By birumut in forum C Programming
    Replies: 12
    Last Post: 03-06-2009, 08:48 PM
  2. Trouble writing to file using fwrite()
    By yougene in forum C Programming
    Replies: 4
    Last Post: 12-30-2008, 04:13 PM
  3. Mutlithreaded file handling
    By nvoigt in forum Windows Programming
    Replies: 11
    Last Post: 06-30-2005, 02:39 PM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21