I'm having issues passing an array struct into a function for processing.
I think I need to pass the function the address of the array, however have got multiple compiler errors and am running out of combinations to try.
The function then needs to return a value to a new struct member.
Here is my best shot!
//-----------------
void Function(struct MyStruct* ptr);
//------------------
int main(){
MyStruct array[MAX];
for (int i=0; i<MAX; i++)
{
File>>array[i].V1;
File>>array[i].V2;
File>>array[i].V3;
File>>array[i].V4;
MyStruct* ptr = &array[i];
array[i].V5 = Function(ptr);
}
}
//-----------------------
void Function(struct MyStruct* ptr)
{
// do something with the struct, how to I access each element in here?
}
Thanks!
mainlooks good. Don't forget to giveFunctiona useful return type that'll matcharray[i].V5, and inside it you may access the members ofMyStructthrough the pointer likeptr->V1,ptr->V2etc