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 can you access memory located at a certain address?
What is header file in c?
Why c is called a mid level programming language?
For what purpose null pointer used?
What is c language in simple words?
Tell us bitwise shift operators?
what value is returned to operating system after program execution?
What is a example of a variable?
What tq means in chat?
What is sizeof int?
Write programs for String Reversal & Palindrome check
All technical questions
What does node * mean?
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
What is ctrl c called?