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 calloc and malloc?

Answer Posted / vadivel t

Hi Jhothi16,
how do u say calloc is for reallocation???..

Ans is,

Both are serving for the purpose of dynamic memory
allocation.
But malloc and calloc differs in two ways.

1.After allocating memory using malloc(), the data elements
in the memory will not be initialised. Means, it contains
garbage values.

But calloc() initialise all the data elements to 0.


2.malloc() allocates memory in terms of bytes.it accepts
only one argument, which says no of bytes to be allocated.

But calloc() allocates memory interms of blocks. it is
widely used when there is a need to allocated memory for an
array.

it accepts two arguments, 1st says, no of blocks to be
allocated and next argument says the size of the block.

ex:

calloc(10, sizeof(int))

-> it allocates 40 bytes, if the compiler allocates 4 bytes
for an int variable.

Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of data types and explain?

1075


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

2006


What is nested structure?

1025


What does != Mean in c?

1031


What is the right way to use errno?

1035


What is d'n in c?

1104


pierrot's divisor program using c or c++ code

2220


What is the meaning of typedef struct in c?

1050


Why is python slower than c?

1064


What is string in c language?

1129


Explain the difference between strcpy() and memcpy() function?

988


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

1027


Is this program statement valid? INT = 10.50;

1128


What is the -> in c?

994


Who is the founder of c language?

1147