大家好,问一个c的free问题,它好像没有释放掉指针
代码如下:
#include <stdio.h>
#include <stdlib.h>
struct test
{
int a;
struct test *next;
};
int main()
{
struct test test0={10};
struct test *test1 = (struct test *)malloc(sizeof(struct test));
test1->a=20;
test1->next = &test0;
free(test1);
printf("%d %d",test1->a,(*test1->next).a);
}
输出test1->a为0 ,(*test1->next).a为10
说明结构体里的变量a已经被free释放掉了,而test1里的指针变量next却还可以被访问??