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
Is it possible to pass an entire structure to functions?
Why is event driven programming or procedural programming, better within specific scenario?
Which type of language is c?
What are keywords in c with examples?
Can a function argument have default value?
What extern c means?
Why should I prototype a function?
What are the types of c language?
Explain how can you restore a redirected standard stream?
What is logical error?
how logic is used
How can I sort a linked list?
What is the concatenation operator?
Differentiate between the expression “++a” and “a++”?
code for replace tabs with equivalent number of blanks