free ()函数

来源:互联网 发布:sqlserver jar 驱动包 编辑:程序博客网 时间:2024/05/16 10:00
 

free

语法:

 
  #include <stdlib.h>
  void free( void *ptr );

功能: 函数释放指针ptr指向的空间,以供以后使用。指针ptr 必须由先前对malloc(), calloc(), realloc()的调用返回。例如:

    typedef struct data_type {
      int age;
      char name[20];
    } data;
    
    data *willy;
    willy = (data*) malloc( sizeof(data) );
    ...
    free( willy );
原创粉丝点击