如图所示,结构体数组的地址回连续不?怎么访问结构体数组的成员?
typedef struct {
__IOM uint32_t PCR;
}PCR_Type;
typedef struct {
__O uint32_t VERID; /*< * PORTA Version Number Register offset 0x0 * >*/
__IM uint32_t RESERVED; /*< * reserved offset 0x4 * >*/
__IOM uint32_t GLBDAT; /*< * Global Pin Data Register offset 0x8 * >*/
__IM uint32_t GLBCTL; /*< * Global Pin Control Register offset 0xC * >*/
PCR_Type pcr[18]; /*< * PORT Pin Control Registe offset 40* >*/
}PORT_Type;
1,数组各元素的地址当然也是连续的,不管在哪里都一样
2,访问方式和其它数组一样,数组的一个成员就是一个结构体。
数组元素在内存里是连续排列的,你可以通过指针或数组下标来访问各个元素,结构体数组也一样