Both malloc and calloc functions are used for allocation of memory during runtime . Only difference between them is that calloc initializes the memory block allocated with zero while malloc doesn’t initializes them. So suppose you declare a dynamic array using malloc then elements of array will contain garbage value.
When should we use malloc ()?
Both malloc and calloc functions are used for allocation of memory during runtime . Only difference between them is that calloc initializes the memory block allocated with zero while malloc doesn’t initializes them. So suppose you declare a dynamic array using malloc then elements of array will contain garbage value.