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
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
Is c still used?
What is the difference between test design and test case design?
What is the difference between malloc() and calloc() function in c language?
What is pass by reference in c?
Is there a way to compare two structure variables?
Tell me when would you use a pointer to a function?
Calculate 1*2*3*____*n using recursive function??
What is c programing language?
What are global variables?
How can I remove the leading spaces from a string?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
What is meant by realloc()?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What is nested structure in c?