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
How to establish connection with oracle database software from c language?
What is return type in c?
Explain the advantages of using macro in c language?
What are the advantages and disadvantages of pointers?
Do pointers take up memory?
Explain what is wrong with this statement? Myname = ?robin?;
Explain why c is faster than c++?
What does the c in ctime mean?
What is c language used for?
how to find anagram without using string functions using only loops in c programming
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Explain what is dynamic data structure?
What are the different types of endless loops?
What's the total generic pointer type?
What are nested functions in c?