1,calloc 和malloc
calloc分配为数组,并把所有位都初始化为0
释放都用free
realloc两个参数,一个是指针,包含前面用malloc,calloc,realloc返回的地址,另一个是要分配的新内存的字节数。先释放第一个指针参数引用的之前分配的内存,然后重新分配该内存区域,以满足第二个参数指定的新请求。第二个参数的值不应超过以前分配的字节数。
2,函数指针
int (*pfunction) (int)
表示一个参数为整形和返回值为整形的函数指针pfunction
int sum(int a,int b);
int (*pfunction) (int,int) = sum ;
int result = pfunction(3,6)
int product(int a,int b )
pfunction = product;
可用typedef简化
typedef int (*function_pointer)(int,int); 定义类型
function_pointer pfun;
3,函数指针数组
int (*pfunctions[10]) (int)