Okay so I keep running into this same problem and I have tried hard to find a solution with no success. Basically, I can get pointers working with functions, but when I change it to the pointer pointing to an array of structures I will get memory access errors.
Would the function prototype for a function receiving a pointer to an array of structures look like this:
void sample (struct myStruct *sampPoint);
?
When I write the definition for this function and I try to write to the pointers' members I get memory access errors. This is driving me insane. All help is highly appreciated. Thanks.
struct S
{
int a;
int b;
};
void Foo(S* ptr)
{
ptr[2].b = ptr[0].a; // ptr[2] demands there be at least 3 structs in the array
}
int main()
{
S three[3];
Foo( three ); // works
S two[2];
Foo( two ); // compiles okay, but explodes when run because 'two' isn't big enough
return 0;
};