What is the difference between malloc() and calloc() ?

Difference between malloc and calloc :

malloc() calloc()
Malloc allocates a single block of memory. Calloc allocates a contiguous block of memory having same size.
It takes a single parameter i.e. total size to be allocated.  It takes two parameters ,no of blocks required and size of each.
Memory locations contain garbage values.  It initializes the value to 0.

Leave a Reply

Your email address will not be published. Required fields are marked *