0

How can I return the address of the target if i have the following struct and the prototype for the function is also as follows

struct inner{
 int foo;
};

struct outter{
 struct inner innerStruct[100];
};

struct inner * foo1(int target){
}

NOTE** I don't need the algorithm to find the target, I just want to know how to return the address of the target if found.

1 Answers1

2

If out is a pointer to a struct outter, then out->innerStruct is the array innerStruct inside that structure, and out->innerStruct[i] is element i of that array, and &out->innerStruct[i] is the address of that element.

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312