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


Please Help Members By Posting Answers For Below Questions

Why c language?

656


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

928


All technical questions

1524


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..

1602


Are enumerations really portable?

602






What are the different file extensions involved when programming in C?

776


Disadvantages of C language.

668


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

774


What is uint8 in c?

652


What do you mean by Recursion Function?

636


If fflush wont work, what can I use to flush input?

629


What are the header files used in c language?

599


write a program in c language to print your bio-data on the screen by using functions.

6259


What is the code in while loop that returns the output of given code?

1358


Explain threaded binary trees?

688