Dear everyone,
My idea is create a pointer array point to multi structs as below:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef struct {
volatile unsigned char mR;
volatile int iB;
}sensor;
sensor uL0 = {
10,
1,
};
sensor uL1 = {
10,
1,
};
sensor uL2 = {
10,
1,
};
int main(void) {
struct sensor *ptr[3];
ptr[0] = &uL0;
printf("%d",ptr[0].iB);
return EXIT_SUCCESS;
}
I want to use pointer ptr[0] to point to uL0, but above code has problem.
Please help to give me some suggestions to solve.
Thank you so much!