There are two major differences between malloc
and calloc
in C programming language: first, in the number of arguments. The malloc()
takes a single argument, while calloc()
takess two. Second, malloc()
does not initialize the memory allocated, while calloc()
initializes the allocated memory to ZERO.
Both malloc
and calloc
are used in C language for dynamic memory allocation they obtain blocks of memory dynamically. Dynamic memory allocation is a unique feature of C language that enables us to create data types and structures of any size and length suitable to our programs.