Binary I/O for Newbie

Tobias Brandt tob.brandt at googlemail.com
Mon Feb 27 11:43:52 PST 2012


>> 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. :)

Yep, good catch.

>> 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.

Correct me if I'm wrong. But as far a I know the C standard also
allows arbitrary alignment.


More information about the Digitalmars-d-learn mailing list