JessyEzzy
asked on
Reading Binary data
I have a file of binary 1s and 0s that I want to read in chunks of size 64, for example read the 1st 64 bits into an integer array of size 64, proccess it and then read the next 64 and so on until the end of file.
How would I do this, I couldn't find a function that reads integer data from file, I tried using the function get() and cast the returned value but it gave me an array of 48s and 49s which are the ASCIIs of 1s and 0s.
Thanks in advance.
How would I do this, I couldn't find a function that reads integer data from file, I tried using the function get() and cast the returned value but it gave me an array of 48s and 49s which are the ASCIIs of 1s and 0s.
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
when you read the data using *getline* function ..then add if statement inside the for loop ..
for(int i =0; i<size; i++){
if(array[i] == '1')
// process it
else
// when it is not '1' do whatever you want ..
}