Fseek and binary files

This is a discussion on Fseek and binary files within the C Programming forums, part of the General Programming Boards category; Here is what my program needs to do. I am trying to open a binary file and read 16 bits ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    2

    Fseek and binary files

    Here is what my program needs to do. I am trying to open a binary file and read 16 bits into a structure which I am able to do. I then look at the first 8 bits and depending on what number it is, I need to skip that number of bits and then read another 16 bits.

    I am fairly new to C and extremely new to file I/O, especially with .bin files. How exactly do I move a certain number of bits rather than bytes?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    How exactly do I move a certain number of bits rather than bytes?
    you can't, you have to make do with bytes.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    2
    Quote Originally Posted by bithub
    you can't, you have to make do with bytes.
    Nevermind. I read the assignment wrong and thus, made my life a living hell for the past 4 hours or so.

    Thanks for the quick reply.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fseek failing - Error: Invalid argument
    By avi2886 in forum C Programming
    Replies: 14
    Last Post: 05-14-2009, 09:49 PM
  2. fopening and fseeking: text or binary file?
    By stabu in forum C Programming
    Replies: 6
    Last Post: 07-31-2008, 02:43 PM
  3. Searching Binary Files for a Pattern
    By CaptainMorgan in forum C Programming
    Replies: 16
    Last Post: 06-17-2007, 07:04 PM
  4. Question about binary trees and files
    By satory in forum C Programming
    Replies: 9
    Last Post: 03-06-2006, 06:28 AM
  5. Binary files
    By docetes in forum C Programming
    Replies: 2
    Last Post: 04-21-2005, 02:42 PM

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