#include #include struct A { int x; } var_global; struct B { int y; }; int main() { /* Case 1. Casting of heap address. */ struct A *var_local1 = (struct A *)malloc(sizeof(struct A)); struct B *var_local2 = (struct B *)var_local1; printf("The same addresses of different fields of different structures: %p %p\n", &var_local1->x, &var_local2->y); /* Case 2. Casting of global variable address. */ var_local2 = (struct B *)&var_global; printf("The same addresses of different fields of different structures: %p %p\n", &var_global.x, &var_local2->y); return 0; }