Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 19 No

Post New Answer

More C Interview Questions

How do you print only part of a string?

0 Answers  


What are the string functions? List some string functions available in c.

0 Answers  


Tell us two differences between new () and malloc ()?

0 Answers   Adobe,


What is an expression?

0 Answers  


any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above

0 Answers  






Write a code to generate a series where the next element is the sum of last k terms.

0 Answers   Aspiring Minds,


in which language c language is written?

2 Answers  


What are the different types of control structures?

0 Answers  


In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?

4 Answers  


Why should I prototype a function?

0 Answers  


SRUCTURE PROGRAMMING

3 Answers   CTS, Wipro,


Why does everyone say not to use gets?

0 Answers  






Categories