A
aengus
Hi,
I am looking to find out how to deal with the BYTE datatype in VC, as
used below:
This struct is part of the API for a Garmin GPS unit:
typedef struct
{
unsigned char mPacketType; // 0 1 byte
unsigned char mReserved1; // 1 1 byte
unsigned short mReserved2; // 2,3 2 bytes
unsigned short mPacketId; // 4,5 2 bytes
unsigned short mReserved3; // 6,7 2 bytes
unsigned long mDataSize; // 8-11 4 bytes
BYTE mData[1]; // 12+ x bytes
} Packet_t;
The last element mData holds a variable amount of data the size of
which is stored in mDataSize. I am unsure how to deal with it.
In one case, I need to store an unsigned short in it, so I have
written:
mDataSize = sizeof(unsigned short);
mData[0] = 5;
But this does not seem to work... can anyone help?
(Visual Studio .NET 2002, Intel Centrino)
thanks,
Aengus.
I am looking to find out how to deal with the BYTE datatype in VC, as
used below:
This struct is part of the API for a Garmin GPS unit:
typedef struct
{
unsigned char mPacketType; // 0 1 byte
unsigned char mReserved1; // 1 1 byte
unsigned short mReserved2; // 2,3 2 bytes
unsigned short mPacketId; // 4,5 2 bytes
unsigned short mReserved3; // 6,7 2 bytes
unsigned long mDataSize; // 8-11 4 bytes
BYTE mData[1]; // 12+ x bytes
} Packet_t;
The last element mData holds a variable amount of data the size of
which is stored in mDataSize. I am unsure how to deal with it.
In one case, I need to store an unsigned short in it, so I have
written:
mDataSize = sizeof(unsigned short);
mData[0] = 5;
But this does not seem to work... can anyone help?
(Visual Studio .NET 2002, Intel Centrino)
thanks,
Aengus.