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
What are the two types of functions in c?
What is the 'named constructor idiom'?
What are loops in c?
What are the 5 elements of structure?
What is nested structure?
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
In a switch statement, what will happen if a break statement is omitted?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
What is structure of c program?
Do character constants represent numerical values?
why programs in c are running with out #include
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
How can you check to see whether a symbol is defined?
Why should I prototype a function?