I'm having a bit of trouble of reading in 32 bit chunks from a file and then storing it into an integer, and then repeating the process for the entire file. Is there an easier way to do this rather than bit by bit?
Reading in bits from a file
Collapse
X
-
Tags: None
-
Originally posted by DarkArchonI'm having a bit of trouble of reading in 32 bit chunks from a file and then storing it into an integer, and then repeating the process for the entire file. Is there an easier way to do this rather than bit by bit?
If you read from a file then you are reading a byte and 1 character in a file is 1 byte.
Raghuram -
What if your file format?
Can you use binary read?
If so, you can read into an array of int of any size with one read.Comment
-
The file is a binary file. And yes ideally I'd read in the file and put it into a unsigned int array. I know in C++ you can use the fstream to get binary files, but what do you use for C?Comment
-
C uses a FILE*.
BTW: Dig deep enough into C++ streams and you will find the FILE*.
You should be able to fread() to an address for a number of bytes.Comment
Comment