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.