这段代码的问题是,明明是在函数中定义的结构体,那应该在栈上分配了内存,当函数结束之后
这个结构体变量应该就没有了呀,传出的地址也就是无效值,可是为什么结果显示这个结构体还
存在呢,求大神详细解释下,百思不得其解
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct
{
int data;
}node;
node * fun1()
{
node h;
h.data = 1;
return &h;
}
void main()
{
node *p;
p = fun1();
printf("%d\n",p->data);
system("pause");
}