c - 具有结构指针数组的嵌套结构

标签 c pointers structure zigbee

主要结构

typedef struct {
   uint8 u8Status;
   uint8 u8NeighborTableEntries;
   uint8 u8StartIndex;
   uint8 u8NeighborTableListCount;
   /* Rest of the message is variable length */
   ZPS_tsAplZdpDiscNtEntry* pNetworkTableList;
                                              //pNetworkTableList is a pointer to 
                                              //the first   
                                              //entry in the list of reported
                                              //Neighbour table entries
 } ZPS_tsAplZdpMgmtLqiRsp;


typedef struct
{
   uint64 u64ExtPanId;
   uint64 u64ExtendedAddress;
   uint16 u16NwkAddr;
   uint8 u8LinkQuality;
   uint8 u8Depth;
   union
   {
     struct
     {
       unsigned u2DeviceType:2;
       unsigned u2RxOnWhenIdle:2;
       unsigned u2Relationship:3;
       unsigned u1Reserved1:1;
       unsigned u2PermitJoining:2;
       unsigned u6Reserved2:6;
    } ;
    uint8 au8Field[2];
 } uAncAttrs;
} ZPS_tsAplZdpDiscNtEntry;

我已经定义了 ZPS_tsAplZdpMgmtLqiRsp *指针;

这似乎没问题..

pointer->u8Status
pointer->u8NeighborTableEntries
pointer->u8StartIndex
pointer->u8NeighborTableListCount

但是我如何访问 ZPS_tsAplZdpDiscNtEntry 结构中的这些值

最佳答案

您可以通过以下方式访问该数组:pointer->pNetworkTableList 因此从那里您可以访问结构的所有元素..

例如访问索引为0的元素的u64ExtPanId:

pointer->pNetworkTableList[0].u64ExtPanId = 1232;

关于c - 具有结构指针数组的嵌套结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9111421/

相关文章:

CUDA 的 cudaMemcpyToSymbol() 抛出 "invalid argument"错误

c++ - 在 C/C++ 中高效地在十六进制、二进制和十进制之间转换

c++ - 使用其指针从列表中删除项目

无法使用 VB 从 C 函数读取 char *

c++ - 指向模板类成员函数的函数指针? (C++)

c - 简单C : atof giving wrong value

c - 如何通过指向指针的指针访问结构成员

java - 正确的属性方法

c++ - 在 C++ 中创建堆上的结构数组

c - 从函数的 main 内部编辑值