Difference between malloc and calloc

When calloc is used to allocate a block of memory, the allocated region is initialized to zeroes. In contrast, malloc does not touch the contents of the allocated block of memory, which means it contains garbage values. This could potentially be a security risk because the contents of memory are unpredictable and programming errors may result in a leak of these contents.

Function calloc allocates a region of memory large enough to hold “n elements” of “size” bytes each. Also initializes contents of memory to zeroes. malloc allocates “size” bytes of memory.
Number of arguments calloc has 2 arguments malloc has 1 argument
Syntax void *calloc (number_of_blocks, size_of_each_block_in_bytes); void *malloc (size_in_bytes);
Contents of allocated memory Calloc allocated region is initialized to zero. Malloc contents of allocated memory are not changed. i.e., the memory contains unpredictable or garbage values. This presents a risk.
Return value void pointer (void *). If the allocation succeeds, a pointer to the block of memory is returned. If the allocation of memory fails, a NULL pointer is returned. void pointer (void *). If the allocation succeeds, a pointer to the block of memory is returned. If the allocation of memory fails, a NULL pointer is returned.