现在的位置: 首页 > 综合 > 正文

linux free

2014年09月05日 ⁄ 综合 ⁄ 共 292字 ⁄ 字号 评论关闭

free(C语言提供的库函数)

原型: void free(void *ptr)
功 能: 释放ptr指向的存储空间。被释放的空间通常被送入可用存储区池,以后可在调用malloc、realloc以及calloc函数来再分配。
程序例:
#include
#include
#include
#include
int main(void)
{
char *str;
str = (char *)malloc(10);
if(str == NULL){
perror("malloc");
exit(1);
}
strcpy(str, "Hello");
printf("String is %s\n", str);
free(str);
return 0;
}

抱歉!评论已关闭.