Moschops
Practically a Posting Shark
888 posts since Sep 2008
Reputation Points: 297
Solved Threads: 170
Skill Endorsements: 5
mvmalderen
Posting Maven
2,612 posts since Feb 2009
Reputation Points: 2,221
Solved Threads: 280
Skill Endorsements: 36
offsetof cannot be used in this case because u dont know the member's name but only the address of that member :(
Whoever gave you this exercise is either mistaken that it's possible, or expecting a non-portable hack. Either way, you need to get clarification, because within standard C there's no solution. You simply cannot find the base address of a structure instance given only a pointer to one of its members and the structure name.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,483
Solved Threads: 1,407
Skill Endorsements: 54