reading binary files

This is a discussion on reading binary files within the C Programming forums, part of the General Programming Boards category; I am confused on how to read in a certain amount of bytes at a time as hex numbers from ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    88

    reading binary files

    I am confused on how to read in a certain amount of bytes at a time as hex numbers from a binary file.
    I want to open a binary file and read the first 4 bytes. can anyone give me an example of how to do this after the file is opened.

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    You should take a look at the fread() function. I think that will do what you need.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    88
    alright, once I have read in these bytes. How can I compare it to see if it is the right 4 bytes

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a file in binary question
    By Dan17 in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 01:28 AM
  2. Reading Binary files
    By earth_angel in forum C++ Programming
    Replies: 10
    Last Post: 07-12-2005, 07:48 AM
  3. Reading data from a binary file
    By John22 in forum C Programming
    Replies: 7
    Last Post: 12-06-2002, 02:00 PM
  4. problem reading files in C
    By angelfly in forum C Programming
    Replies: 9
    Last Post: 10-10-2001, 12:58 PM
  5. Need Advice in reading files
    By jon in forum C Programming
    Replies: 4
    Last Post: 10-07-2001, 08:27 AM

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