Hi all, i'd like clear difference b/w those 2 functions.
There are 2 differences.
First, is in the number of arguments. malloc() takes a single argument(memory required in bytes), while calloc() needs 2 arguments(number of variables to allocate memory, size in bytes of a single variable).
Secondly, malloc() doesnot initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.
The difference b/w malloc and calloc are: 1. malloc() allocates byte of memory where as calloc()allocates block of memory.
malloc(s); returns a pointer for enough storage for an object of s bytes. calloc(n,s); returns a pointer for enough contiguous storage for n objects,each of s bytes. The storage is all initialised to zeros.