struct foo
{
char c;
short s;
void* p;
int i;
};
int main()
{
cout << "sizeof(foo)=" << sizeof(foo) << endl;
foo f;
cout << "address of c: " << reinterpret_cast<void*>(&f.c) << endl;
cout << "address of s: " << reinterpret_cast<void*>(&f.s) << endl;
cout << "address of p: " << reinterpret_cast<void*>(&f.p) << endl;
cout << "address of i: " << reinterpret_cast<void*>(&f.i) << endl;
cout << "distance between s and c: " << reinterpret_cast<char*>(&f.s) - reinterpret_cast<char*>(&f.c) << endl;
cout << "distance between p and s: " << reinterpret_cast<char*>(&f.p) - reinterpret_cast<char*>(&f.s) << endl;
cout << "distance between p and c: " << reinterpret_cast<char*>(&f.p) - reinterpret_cast<char*>(&f.c) << endl;
cout << "distance between i and p: " << reinterpret_cast<char*>(&f.i) - reinterpret_cast<char*>(&f.p) << endl;
}