简体   繁体   中英

How to return the address of inner struct given pointer to outter struct in c

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM