例如
typedef struct
{
bool streamValid;
dword dateTime;
dword timeStamp;
stream_data[800];
} RadioDataA;
例。其中 stream_data[800]
包含:
**Variable** **Length (in bits)**
packetID 8
packetL 8
versionMajor 4
versionMinor 4
radioID 8
等..
我需要写:
void unpackData(radioDataA *streamData, MA_DataA *maData)
{
//unpack streamData (from above) & put some of the data into maData
//How do I read in bits of data? I know it's by groups of 8 but I don't understand how.
//MAData is also a struct.
}
我不确定我是否理解正确,但你为什么不能这样做:
memcpy(maData, streamData->stream_data, sizeof(MA_DataA));
这会将字节数组中包含的数据完全复制到结构中。
我是一名优秀的程序员,十分优秀!