Programming question:
How to find the offset between different fields (ex. between 'rate' and 'rentee') without declaring an instance of the following C struct?
u should calculate byte number that each data type reserve in ram then start from the structure begining point with zero then add the number of byte that each variable take in ram.it is very simple.
It is hard ot calculate it by hand, because alingment is compiler dependent (at least in x86 world). But to make it automagically, you could use an idea from stddef.h of DJGPP:
#define offsetof(s_type, mbr) ((size_t) &((s_type *)0)->mbr).
The rest is and easy calculation.
Hope it helps,
Jan
jhbbunch, I really do not know, why you evaluate the the intention or code instead of providing your answers. The kukurigu's question is completely legal whatever intention is behind it. By the way, offsetof() macro is a part of standard system headers of C compilers and some interesting details and ideas about it can be found at hxxp://www.embedded.com/columns/technicalinsights/18312031?_requestid=19902.