// This is an example of getting an offset into a struct to pull a value
// dynamically. Useful in strange but dirty situations.
// Be aware that optimizing compilers may rearrainge your struct format,
// macro or other compiler trick to let it divulge the memory offset is
// safer than adding it up on your own.
#include "stdafx.h"
#include "stddef.h"
int _tmain(int argc, _TCHAR* argv[])
{
struct stooge
{
float eenie;
float meenie;
float miny;
float moe;
};
struct stooge nyuck[100];
size_t upset = offsetof(stooge,miny);
nyuck[42].eenie = 16.0;
nyuck[42].meenie = 22.5;
nyuck[42].miny = 4.25f;
nyuck[42].moe = 28.5;
char* base = (char*)&nyuck[42];
float test = *(float*)(upset + base);
printf("value is %0.2f",test);
return 0;
}