I'm looking for a mechanism to create an array of pointers to certain elements within a multi layered array of structs.
I currently have 2 structs defined. One for month and one for day.
struct Day
{
uint8_t ValueA;
uint8_t ValueB;
uint8_t ValueC;
uint8_t ValueD;
uint8_t ValueE;
uint32_t TimeA;
uint32_t TimeB;
};
struct Month
{
uint8_t Month;
uint8_t Year;
uint8_t DaysInMonth;
uint8_t ValueA;
Day Days[31];
};
in my code I then create the months array as follows. There are only 2 month arrays as i store current and next month.
Month Months[2];
I want to create another array that stores pointers to the next 7 days (its for weather forcast).
So for example (in sudo as I know this syntax does not work) I want to do something like this:
int * forecast[7];
forecast[0] = &Months[0].Days[5];
forecast[1] = &Months[0].Days[6];
forecast[2] = &Months[0].Days[7];
forecast[3] = &Months[0].Days[8];
forecast[4] = &Months[0].Days[9];
forecast[5] = &Months[0].Days[10];
forecast[6] = &Months[0].Days[11];
But this gives me the error:
cannot convert 'Day*' to 'int*' in initialization
Any suggestions much appreciated!