read bit's from any file

This is a discussion on read bit's from any file within the C Programming forums, part of the General Programming Boards category; Hi, i want to read bit-to-bit from a file, and do comparison's with that. something like this: int Y = ...

  1. #1
    Registered User scrapedbr's Avatar
    Join Date
    May 2003
    Posts
    19

    read bit's from any file

    Hi, i want to read bit-to-bit from a file, and do comparison's with that.

    something like this:

    int Y = 1;
    int X = 0;

    read from file ( text or binary)
    X = 1 bit, and do the comparison, if (X) find 1, else find 0.
    or
    read 4 bits to X and
    if (X == 1001) be happy
    else nothing.....

    how can i do that ??
    cscience.org
    gobolinux.org
    Gobolinux user: 00101100

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    The smallest amount of data you can read from a file is one byte. Once you have that byte in memory, you can use bitwise operations on it in the normal manner
    http://faq.cprogramming.com/cgi-bin/...&id=1043284351
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 09:57 AM

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