小编Kat*_*ate的帖子

为什么malloc没有被释放?

#include <stdio.h>
#include <stdlib.h>
typedef struct node{
    struct node *pre;
    struct node *next;
    int data;
}NODE; //struct declaration

int main(){

    NODE *new_node=(NODE*)malloc(sizeof(NODE)); //memory allocation

    printf("\nnew_node addr: %d\n",new_node);

    free(new_node); //deallocation

    printf("new_node addr: %d\n",new_node);


}
Run Code Online (Sandbox Code Playgroud)

结果:

new_node addr: 2097152
new_node addr: 2097152
Program ended with exit code: 0
Run Code Online (Sandbox Code Playgroud)

结果为何相同?
我释放new_node的内存.但是new_node有地址.
为什么??

c malloc free

0
推荐指数
2
解决办法
48
查看次数

标签 统计

c ×1

free ×1

malloc ×1