Right now I have a C++ program that reads in two columns of data from a text file using something like
while(!file.eof())
{
double a, b;
file >> a >> b; // extracts 2 floating point values separated by whitespace
// do something with them
}
Now I want to adjust this code to read in two columns of binary data from a .bin file. I still want to treat the values as doubles in the rest of my program. What is the easiest way to accomplish this?
EDIT:
I am writing the binary data like this in a python program. I think of it as being in two columns.
import struct
c = struct.Struct('=ff')
with open('numbers.bin', 'w+') as outf:
for r, k in nonzero:
outf.write(c.pack(r, k))