Binary I/O for Newbie
Ali Çehreli
acehreli at yahoo.com
Mon Feb 27 11:36:03 PST 2012
On 02/27/2012 11:27 AM, Tobias Brandt wrote:
>> So, something like this should work:
>> [...]
>
> It really depends on how you wrote the file originally. If you
> know that it is packed, i.e. 10+32+32+32=106 bytes per record,
> then yes.
You meant 4 bytes per int. :)
> If you wrote to the file with a C++ program, then I guess the
> compiler aligned the data so that the whole struct is 128 bytes
> in size. Technically, the C++ compiler is allowed to do
> anything short of changing the order of the struct fields.
That is correct for non-POD types. The C++ compiler must treat POD
structs essentially as if they are C structs.
Ali
More information about the Digitalmars-d-learn
mailing list