WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?
Answer Posted / chris_sreekanth
malloc() allocates 1 unit(datatype) of memory each time it
is called so to allocate memory for a file read char by
char allocating memory each time for a char till EOF.
calloc allocates sizeof(datatype) bytes to the no of
elements in the file, where by the user can specify the
file size as the second arguement.
char *malloc(sizeof(datatype) )
char *calloc(sizeof(datatype), num of elements)
calloc() is more efficient as memory is allocated in 1
cycle so fewer clock cycles, more faster executiop.
Is This Answer Correct ? | 268 Yes | 63 No |
Post New Answer View All Answers
Explain the red-black trees?
What is call by reference in functions?
What are the differences between new and malloc in C?
Can a pointer be volatile in c?
Why c is called a middle level language?
What is difference between arrays and pointers?
What is a program flowchart and how does it help in writing a program?
What is structure in c definition?
Explain what is wrong with this program statement?
What is void main ()?
What is dynamic dispatch in c++?
What is action and transformation in spark?
Why are algorithms important in c program?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
Who is the founder of c language?