What is the difference between "calloc" and "malloc"?

Answers were Sorted based on User's Feedback



What is the difference between "calloc" and "malloc"?..

Answer / shweta

calloc initializes memory with 0 while malloc doesn't
initializes.

Is This Answer Correct ?    25 Yes 4 No

What is the difference between "calloc" and "malloc"?..

Answer / ven

In addiion, calloc requires two parameters whereas ,malloc
only one

Is This Answer Correct ?    19 Yes 6 No

What is the difference between "calloc" and "malloc"?..

Answer / vijay

Calloc allocates the array of blocks of memory whearas
malloc allocates the memory of the size given as an
argument.

Is This Answer Correct ?    12 Yes 2 No

What is the difference between "calloc" and "malloc"?..

Answer / saugat biswas

Malloc:
Malloc allocates memory but does not initialize it.
Example: char *szPtr = ( char* ) malloc( sizeof( char ) *
100 );
Here szPtr is assigned 100 bytes. But the memory is not
initialized. It contains garbage.

Calloc:
Allocates a block of memory for an array of 'n' elements,
each of them 'l' bytes long, and initializes all its bits
to zero.
Example: char *szPtr = ( char* ) calloc( 100, sizeof(
char ));
Here szPtr is assigned 100 bytes & the memory is
initialized to 0.

Is This Answer Correct ?    11 Yes 2 No

What is the difference between "calloc" and "malloc"?..

Answer / gallanticscorp

calloc means alloting memory dynamically
malloc means alloting memory at first and it is fixed

Is This Answer Correct ?    5 Yes 3 No

What is the difference between "calloc" and "malloc"?..

Answer / subhrajit

mallco is used in c language for static memory location in
heap area and i donot no the calloc.

Is This Answer Correct ?    1 Yes 0 No

What is the difference between "calloc" and "malloc"?..

Answer / samveethsingh

malloc:
malloc create the single block of given size by user
calloc:
calloc creates multiple blocks of given size

Is This Answer Correct ?    0 Yes 0 No

What is the difference between "calloc" and "malloc"?..

Answer / edwin

malloc - create the memory space

calloc-calculate the memory space

Is This Answer Correct ?    0 Yes 4 No

What is the difference between "calloc" and "malloc"?..

Answer / srikanth

MALLOC ASSIGNS O VALUE , WHERE AS CALLOC ASSIGNS GARBAGE
VALUE.

Is This Answer Correct ?    3 Yes 27 No

Post New Answer

More C++ General Interview Questions

What is the auto keyword good for in c++?

0 Answers  


write the prime no program in c++?

16 Answers  


What are the debugging methods you use when came across a problem?

1 Answers  


If dog is a friend of boy, is boy a friend of dog?

0 Answers  


When should we use container classes instead of arrays?

0 Answers  






what is oops and list its features in c++?

0 Answers  


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

0 Answers  


What does ios :: app do in c++?

0 Answers  


Is there a c++ certification?

0 Answers  


Write any small program that will compile in "C" but not in "C++"

10 Answers   Honeywell,


What is the difference between passing by reference and passing a reference?

0 Answers  


What's c++ used for?

0 Answers  


Categories