I have a function which returns address as following
struct node *create_node(int data) { struct node *temp; temp = (struct node *)malloc(sizeof(struct node)); temp->data=data; temp->next=NULL; printf("create node temp->data=%d\n",temp->data); return temp; }
where struct node is
struct node { int data; struct node *next; };
How can I see in printf("") the address stored in temp?
UPDATE
If I check the adressed in gdb the addresses are coming in hex number format i.e. 0x602010 where as same address in printf("%p",temp)
is coming in a different number which is different from what I saw in gdb print command.
Use the pointer address format specifier %p
:
printf("Address: %p\n", (void *)temp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With