0
现在我有一个C++程序,在两列数据从文本文件使用类似二进制数据
while(!file.eof())
{
double a, b;
file >> a >> b; // extracts 2 floating point values separated by whitespace
// do something with them
}
现在我想调整这个代码的两列读取读取列读来自.bin文件的二进制数据。我仍然希望在我的程序的其余部分将这些值视为双打。什么是最简单的方法来完成这一点?
编辑:
我写这样的二进制数据的Python程序。我认为它分为两列。
import struct
c = struct.Struct('=ff')
with open('numbers.bin', 'w+') as outf:
for r, k in nonzero:
outf.write(c.pack(r, k))
http://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong – chris 2013-03-22 00:52:50
你是什么意思的二进制两列数据?两项? 'fread' 4个字节两次 – 2013-03-22 01:07:09