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
program to convert a integer to string in c language'
What is atoi and atof in c?
What are the benefits of c language?
Place the #include statement must be written in the program?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
What is structure data type in c?
How do we make a global variable accessible across files? Explain the extern keyword?
What is the difference between new and malloc functions?
Explain what are linked list?
Is c programming hard?
Why is c fast?
What does %d do?
What would be an example of a structure analogous to structure c?
What is the advantage of a random access file?
What is the use of sizeof () in c?