Binary I/O for Newbie

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


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

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.

You could just let your C++ program print out sizeof(TaqIdx) or
manually divide the file size by the number of records (if you
know it) to make sure.


More information about the Digitalmars-d-learn mailing list