E
enliteneer
I have an array of structures (my own typedef) that I wish to pass to
a function.
Since the array with the structs is rather large, I would like to
pass
a pointer to just the first element and have the callee function
recast
it as an array instead of just a pointer to the first element of the
array..
Something like...
typedef struct
{
int structElement;
}myStruct;
myStruct myArray[5];
main()
{
foobar( &(myArray[0]);
}
and..
foobar ( myStruct *pElement)
{
myStruct recastArray[] = pElement;
which then, ideally, I could index...
val = recastArray[2].structElement;
}
The problem is, this line:
myStruct recastArray[] = pElement;
doesnt compile, citing an 'invalid intializer'. How can I do this?
a function.
Since the array with the structs is rather large, I would like to
pass
a pointer to just the first element and have the callee function
recast
it as an array instead of just a pointer to the first element of the
array..
Something like...
typedef struct
{
int structElement;
}myStruct;
myStruct myArray[5];
main()
{
foobar( &(myArray[0]);
}
and..
foobar ( myStruct *pElement)
{
myStruct recastArray[] = pElement;
which then, ideally, I could index...
val = recastArray[2].structElement;
}
The problem is, this line:
myStruct recastArray[] = pElement;
doesnt compile, citing an 'invalid intializer'. How can I do this?