I am working with a binary file structure. The code example for reading the data is in C, and I need to read it in Delphi. I hasten to add I have no C programming experience.
Given the following
typedef struct {
uchar ID, DataSource;
ushort ChecksumOffset;
uchar Spare, NDataTypes;
ushort Offset [256];
} HeaderType;
...
typedef struct {
ushort ID;
...
ushort DistanceToBin1Middle,TransmitLength;
} FixLeaderType;
...
HeaderType *HdrPtr;
FixLeaderType *FLdrPtr;
unsigned char RcvBuff[8192];
void DecodeBBensemble( void )
{
unsigned short i, *IDptr, ID;
FLdrPtr = (FixLeaderType *)&RcvBuff [ HdrPtr->Offset[0] ];
if (FLdrPtr->NBins > 128)
FLdrPtr->NBins = 32;
...
The bit I am having difficulty following is this:
FLdrPtr = (FixLeaderType *)&RcvBuff [ HdrPtr->Offset[0] ];
From the little I understand, [ HdrPtr->Offset[0] ];
would be returning the value of the first Offset array item from the HeaderType struct pointed to by HdrPtr? So equivalent to HdrPtr^.Offset[0]
?
Then &RcvBuff [ HdrPtr->Offset[0] ];
should be returning the memory address containing the value of the RcvBuff array item indexed, so equivalent to @RecBuff[HdrPtr^.Offset[0]]
?
Then I get lost with (FixLeaderType *)..
. Could someone please help explain exactly what is being referenced by FldrPtr ?