0

I am looking at some old code and I really don't understand it.

There is a header struct

struct my_header {
   UINT32 chksum,
   UINT16 ValueA,
   UINT64 ValueB,
   UINT16 ValueC
};

Then there is a call to fread

fread(&header, 1, sizeof(header), fd);

And here is the contents of the file, via slickedit hex view

F5010000 3906000 50429178 07000000
14000000 0000000 00000000 00000000

Once it is read, I inspect the data in the struct, and it looks like this

chksum: 0x00001F5
ValueA: 0x0639
ValueB: 32087556688
ValueC: 0x0014

When you compare what the fread got to the hex dump, it looks almost correct. But things are in some weird order.. for example, chksum is 1F5 but the hex dump is F501. ValueA is 639 but in the hex dump it is 3906...

What exactly is going on?

0 Answers0