I am trying to access a pointer index value from an array of structure pointers:
typedef struct
{
bool status;
uint8_t sensnr;
uint8_t set_vallue;
uint8_t actuval_value;
} temp_t;
//array of struct
temp_t temp[5];
typedef struct
{
uint8_t senspwrsource;
uint8_t sensnr;
uint8_t max_value;
} sensor_t;
//array of structs
sensor_t sens[5];
typedef union {
temp_t temp;
sensor_t sensor;
} temp_sens_t;
typedef struct
{
bool status;
struct temp_sens_t *temp_value[3];
struct temp_sens_t *sensors[3];
char sensor_name[MAX_LEN];
} tempsensors_t;
//array of structures
tempsensors_t sensors[5];
I am able to assign all values but I am not able to read values from struct pointer "temp_value[3]".
So far I have tried like this:
temp_t *tempinfo;
tempinfo = &sensors[1]->temp_value[0];
//trying to access values like this but not working.
teminfo.sensnr ;
How do I access values from an array of struct pointers with index [0 to 2]?
tempinfo->sensor?sensorintempinfo = &sensor[1]->temp_value[0];? Please show a minimal reproducible example.temp_value[3];is trying to access beyond the end of the array