#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef struct {
int a;
short b[2];
} Test2;
typedef struct Test1{
int a;
char b[3];
Test2 c;
struct Test1 *d;
} Test1;
int main() {
Test1 x = {10, "Hi", {5, {-1, 25}}, 0};
Test1 *px = &x;
cout << &px << endl;
cout << &px->d << endl;
Test1 y;
x.d = &y;
cout << px->d << endl;
cout << &px->d->c.b[0] << endl;
cout << &px->d->c.b[1] << endl;
cout << endl;
cout << "px->d->c.b[0]: " << px->d->c.b[0] << endl;
cout << px->d->c.b[1] << endl;
cout << endl;
cout << &px->c.b[0] << endl;
cout << &px->c.b[1] << endl;
cout << &px->c.b[2] << endl;
cout << "px->c.a: " << px->c.a << endl;
cout << px->c.b[0] << endl;
cout << px->c.b[1] << endl;
cout << px->c.b[2] << endl;
cout << endl;
cout << "px->b[0]: " << px->b[0] << endl;
cout << px->b[1] << endl;
printf("px->b[2]: %d\n", px->b[2]);
}
|