【发布时间】:2011-09-18 13:48:40
【问题描述】:
我有一个函数返回地址如下
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;
}
结构节点在哪里
struct node {
int data;
struct node *next;
};
如何在 printf("") 中看到 temp 中存储的地址?
更新
如果我检查 gdb 中的地址,地址将以十六进制数字格式出现,即
0x602010 其中printf("%p",temp) 中的相同地址以不同的数字出现,这与我在 gdb print 命令中看到的不同。
【问题讨论】: