How structure program allocate address
I wrote structure program to know how structure store variable data and where does it store
Code:
#include <stdio.h>
#include <stdlib.h>
struct point
{
int x;
struct point *next;
};
int main ()
{
struct point *new = NULL;
new = malloc (sizeof(*new));
if ( new != NULL)
{
new -> x = 1;
new -> next = NULL;
printf("addresses of a struct variable new : %p \n", (void*)&new);
printf("addresses of a struct object x : %p \n", (void*)&new -> x);
printf("addresses of a struct object next : %p \n", (void*)&new -> next);
printf("Data of a struct object 1 : %d \n", (void*)new -> x);
printf("Data of a struct object 2 : %p \n", (void*)new -> next);
}
return 0;
}
When I compile code I get following output
addresses of a struct variable new : 0061FF1C
addresses of a struct object x : 00750D18
addresses of a struct object next : 00750D1C
Data of a struct object 1 : 1
Data of a struct object 2 : 00000000
i don't understand why the address of a struct variable new and addresses of a struct object next are the same
Can anyone explain why these two address are same ?