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 header file for malloc?

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  In which segment does dynamic memory allocation takes place?

Leave a Reply

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