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
Why c language?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
All technical questions
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
Are enumerations really portable?
What are the different file extensions involved when programming in C?
Disadvantages of C language.
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
What is uint8 in c?
What do you mean by Recursion Function?
If fflush wont work, what can I use to flush input?
What are the header files used in c language?
write a program in c language to print your bio-data on the screen by using functions.
What is the code in while loop that returns the output of given code?
Explain threaded binary trees?