Showing posts with label malloc. Show all posts
Showing posts with label malloc. Show all posts

Saturday, August 20, 2016

Malloc and Calloc

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));