WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?

Answer Posted / smitha

Malloc:
1. Takes only 1 argument- the size of the memory block to
be allocated.
2. Allocates memory as a single contiguous block.
3. Will fail if a single contiguous memory block of
required size is not available.

Calloc:
1. Takes two arguments - the number of memory blocks needed
and the size of each memory block.
2. It may or may not allocate a single contiguous block,
thus will not fail if a single contiguous memory block
of required size is not available.
3. Initialises the memory blocks to 0.

Is This Answer Correct ?    17 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

program to convert a integer to string in c language'

1990


What is atoi and atof in c?

622


What are the benefits of c language?

653


Place the #include statement must be written in the program?

576


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1130






What is structure data type in c?

575


How do we make a global variable accessible across files? Explain the extern keyword?

1428


What is the difference between new and malloc functions?

584


Explain what are linked list?

628


Is c programming hard?

584


Why is c fast?

612


What does %d do?

733


What would be an example of a structure analogous to structure c?

580


What is the advantage of a random access file?

644


What is the use of sizeof () in c?

567