malloc calloc realloc is <stdilb.h> function header file
function prototype:
void the malloc (num_bytes unsigned int)
void calloc (n-size_t, size_t size)
void realloc (PTR void *, size_t new_size)
Let me talk about the difference between malloc and calloc
space malloc allocation of rubbish in value, while calloc full of 0
but the efficiency malloc calloc higher than
# include <stdio.h>
# include <malloc.h>
int main()
{
int* p;
int* pp;
p = (int*)malloc(10 * sizeof(int));
pp = (int*)calloc(10 ,sizeof(int));
printf("malloc的存储空间:\n");
for (int i = 0; i < 10; i++)
{
printf("%d ", *(p+i));
}
printf("\n");
printf("calloc的存储空间:\n");
for (int i = 0; i < 10; i++)
{
printf("%d ", *(pp+i));
}
printf("\n");
return 0;
}