What's the difference between calloc() and malloc()?

Answers were Sorted based on User's Feedback



What's the difference between calloc() and malloc()?..

Answer / guest

calloc() takes two arguments, and initializes the allocated
memory to all-bits-0.

Is This Answer Correct ?    9 Yes 0 No

What's the difference between calloc() and malloc()?..

Answer / k.thejonath

Malloc allocates a block of memory whereas using calloc we
can allocate array of memory blocks and all locations are
initialized to zeros

Is This Answer Correct ?    5 Yes 3 No

What's the difference between calloc() and malloc()?..

Answer / valli

the diffence is
1.prototype or no of arguments
calloc takes two arguments
where as malloc takes 1 argument
void *calloc(int ,int);
first argument is no of blocks required
secund argument is no of elementts in each block required
void *malloc(int);
in this total no of bytes reuired are taken as the argument
2.
calloc clears the bytes which are allocated or reserved
where malloc can not guarentee this


sorry for my poor english

Is This Answer Correct ?    2 Yes 1 No

What's the difference between calloc() and malloc()?..

Answer / bhaswati

malloc allocates m bytes means it takes one arguments.but calloc allocate m times n bytes and initialized the memory location to zero.it takes two arguments.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

How many types of functions are there in c?

0 Answers  


What is the meaning of 2d in c?

0 Answers  


write a program that explain #define and # undef directive

1 Answers  


What is the difference between printf and scanf in c?

0 Answers  


i want to job in your company, so how it will be possible.

3 Answers   TCS,






What is the difference between local variable and global variable in c?

0 Answers  


What is difference between structure and union?

0 Answers  


parkside's triangle.. create a program like this.. enter the size: 6 enter the seed: 1 output: 1 23 456 7891 23456 789123 sample2: enter the size: 5 enter the seed: 3 output: 3 45 678 9123 45678 parkside should not exceed 10 while its seed should only be not more than 9..

4 Answers  


Should I learn c before c++?

0 Answers  


How can I implement a delay, or time a users response, with sub-second resolution?

0 Answers  


write a function to find whether a string is palindrome or not and how many palindrome this string contain?

2 Answers   Aptech,


Find greatest number out of 10 number without using loop.

5 Answers   TCS,


Categories