0

我正在使用一个二进制文件,我需要从中获取有用的内容。结构是:

4

1 回答 1

2

Based on a quick look at the file, you don't have an "unknown amt of nulls" anywhere. The format appears to be:

N Bytes: number of animals, integer as text delimited by '\n'
24 Bytes per animal:
    16 Bytes: name of animal padded with 0
    4 Bytes: some 32 bit number (little endian)
    4 Bytes: another 32 bit number (little endian)

You shouldn't be reading this as a text file, but instead as a raw binary file. There's absolutely no need for a stringstream, you can simply parse the number of animals by reading in one byte at a time and adding to the previous value * 10 until you reach '\n'.

于 2013-09-06T15:09:49.963 回答