返回值
此函数不返回任何值。
示例
以下示例显示free函数的用法-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
char *str;
/* Initial memory allocation */
str = (char *) malloc(15);
strcpy(str, "jc2182");
printf("String = %s, Address = %u\n", str, str);
/* Reallocating memory */
str = (char *) realloc(str, 25);
strcat(str, ".com");
printf("String = %s, Address = %u\n", str, str);
/* Deallocate allocated memory */
free(str);
return(0);
}
让我们编译并运行上面的程序,它将产生以下结果-
String = jc2182, Address = 355090448
String = cainiaoya.com, Address = 355090448