Difference between Malloc() and Calloc()
1. malloc() takes one argument while calloc() takes two argument
2. malloc() does not initialize the allocated memory while calloc allocated memory intialized with 0.
3. Both are used for dynamic memory allocation.
4. malloc is faster than calloc
5.Example: int *p=(int *)malloc(sizeof(int));
int *p=(int *)calloc(10,sizeof(int));
1. malloc() takes one argument while calloc() takes two argument
2. malloc() does not initialize the allocated memory while calloc allocated memory intialized with 0.
3. Both are used for dynamic memory allocation.
4. malloc is faster than calloc
5.Example: int *p=(int *)malloc(sizeof(int));
int *p=(int *)calloc(10,sizeof(int));
No comments:
Post a Comment