What is the proper syntax for initializing a pointer to an array of structures?
I have the following definitions:
Code:
typedef struct
{
int Targets;
Target_t targets[TARGETS_MAX];
} TargetList_t;
typedef struct
{
int id;
float distX;
float distY;
}Target_t;
TargetList_t foo[SENS_MAX];
TargetList_t* ptrfoo = &foo;
TargetList_t TL;
TargetList_t* ptrTL = &TL;
If I try to initialize the pointer ptrTL it works fine
Code:
ptrTL->targets[0].distX = 4;
However, in initializing the pointer to foo
Code:
ptrfoo[0]->targets[0].distX = 2;
I get an error saying:
error C2232: '->targets' : left operand has 'struct' type, use '.'
what gives? How can I initialize a pointer to an array of structures?