What is the main difference between calloc() and malloc()?

Options
- calloc() takes a single argument while malloc() needs two arguments
- malloc() takes a single argument while calloc() needs two arguments
- malloc() initializes the allocated memory to ZERO
- calloc() initializes the allocated memory to NULL


CORRECT ANSWER : malloc() takes a single argument while calloc() needs two arguments

Discussion Board
C language

C language am like a jana

Kirti 01-27-2020 06:13 AM

Difference between calloc() & malloc()

malloc()

-malloc stands for memory allocation.
-malloc takes single argument i.e number of bytes.
-It does not initialize the memory allocated.

calloc()

-calloc stands for contiguous allocation.
-calloc takes two arguments i.e number of blocks & size of each block.
-It initializes the allocated memory to ZERO.

Sapna 02-14-2017 06:19 AM

Difference between calloc() and malloc()

- calloc() initializes the allocated memory to zero
- malloc() does not initialize the allocated memory.

Aparna 07-5-2013 03:20 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement