Distinguish between malloc() & calloc() memory allocation

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.

Related posts