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?

Answers were Sorted based on User's Feedback



what is calloc and malloc?..

Answer / 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

what is calloc and malloc?..

Answer / jothi16

calloc means reallocate the memory.malloc used to allocate
the memory

Is This Answer Correct ?    6 Yes 20 No

Post New Answer

More C Interview Questions

What is boolean in c?

0 Answers  


What is structure padding in c?

0 Answers  


write a programming in c to find the sum of all elements in an array through function.

0 Answers  


What are the primitive data types in c?

0 Answers  


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

0 Answers  


What are header files? What are their uses?

0 Answers  


What is the difference between null pointer and wild pointer?

0 Answers  


Explain how can you avoid including a header more than once?

0 Answers  


What does calloc stand for?

0 Answers  


c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above

0 Answers  


what is the difference between 123 and 0123 in c?

0 Answers  


You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pattern string. You are not allowed to create new resulting string. You need to allocate some new memory to given existing string but constraint is you can only allocate memory one time. Allocate memory exactly what you need not more not less.

2 Answers   Microsoft,


Categories