What is the difference between calloc and malloc?A. calloc allocates memory in contiguous bytes, malloc does not ensure contiguous memory allocationB. Memory allocated through calloc need not be freed explicitly, while memory allocated through malloc needs to be freed explicitly.C. calloc initializes the memory by setting all-bits-zero, malloc does not does any zero fill.D. all of the above

Showing Answers 1 - 4 of 4 Answers

BRN Prasad

  • Mar 13th, 2006
 

c

  Was this answer useful?  Yes

snow

  • Apr 27th, 2006
 

There are 2 differences.First, is in the number of arguments. malloc() takes a single argument(memory required in bytes), while calloc() needs 2 arguments(number of variables to allocate memory, size in bytes of a single variable).Secondly, malloc() doesnot initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions