1.

What Is The Difference Between Calloc() And Malloc() ?

Answer»

A block of memory may be allocated using the function malloc. The malloc function reserves a block of memory of specified size and RETURNS a pointer of type void. This means we can assign the base address of the block to any type of pointer.
  Syntax – P = (cast type*)malloc(byte size);
Calloc is also a memory allocation function which is generally USED to allocate memory for ARRAY and STRUCTURE .malloc is used to allocate a single block of storage space, calloc allocates multiple blocks of storage, each of same size and initializes them with ZERO.
Syntax - P = (cast type*)calloc(n,array size);

A block of memory may be allocated using the function malloc. The malloc function reserves a block of memory of specified size and returns a pointer of type void. This means we can assign the base address of the block to any type of pointer.
  Syntax – P = (cast type*)malloc(byte size);
Calloc is also a memory allocation function which is generally used to allocate memory for array and structure .malloc is used to allocate a single block of storage space, calloc allocates multiple blocks of storage, each of same size and initializes them with zero.
Syntax - P = (cast type*)calloc(n,array size);



Discussion

No Comment Found