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.

Sizin İçin Seçtik  What is malloc in C with example?

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

Sizin İçin Seçtik  What is malloc in C with example?

Leave a Reply

Your email address will not be published. Required fields are marked *