Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is a structure in c language. how to initialise a structure in c?

1067


How can I recover the file name given an open stream?

1035


How was c created?

1072


Explain what does it mean when a pointer is used in an if statement?

1076


Are there constructors in c?

1017


How can I direct output to the printer?

1326


How can a process change an environment variable in its caller?

1192


Write a program to print "hello world" without using a semicolon?

1071


What is the significance of scope resolution operator?

1419


How to create struct variables?

1119


What is .obj file in c?

1091


Explain the red-black trees?

1141


What is actual argument?

1071


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

1113


swap 2 numbers without using third variable?

1141