free指针所指向的内容

来源:互联网 发布:大数据的就业前景 编辑:程序博客网 时间:2024/04/24 02:49
#include <stdio.h>#include <stdlib.h>//point 相应于指针的值拷贝void freePoint(char *point) {if (NULL != point){free(point);point = NULL;}}void freepPointPoint(char **point){if (NULL != *point){free(*point);*point = NULL;}}int main(){char *ptemp = NULL;int len = 10;ptemp = (char*)calloc(len, sizeof(char));sprintf(ptemp, "123456789");//freePoint(ptemp); //也会释放空间,但指针依然是野指针freepPointPoint(&ptemp);//释放空间,并将指针置为空getchar();return 0;}