你能知道free()是否在C语言中成功而没有崩溃吗?
如果从malloc()返回的指针等于传递给free()的指针,则free()将始终成功。唯一可用的错误检查是将指针与原始地址的副本进行比较,然后再将其传递给free()。
/*本实验证明:free之后,你释放后的节点中的数据还是原来的值*/
#include <stdio.h>
#include <stdlib.h>
#define ERROR 1
#define SUCCESS 0
typedef struct _node{
int data;
struct _node *next;
}node;
node *gpNode=NULL;
node* CreateNode(node *p){
node*temp=(node*)malloc(sizeof(node));
printf("Create node value is:%d\n",temp);
if(temp==NULL){
printf("malloc fail\n");
}
temp->next=NULL;
return te