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

What is a example of a variable?

0 Answers  


What is %s and %d in c?

0 Answers  


How #define works?

0 Answers  


HOW CAN ADD OUR FUNCTION IN LIBRARY.

5 Answers  


Explain low-order bytes.

0 Answers  






What is a pointer in c plus plus?

0 Answers  


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

0 Answers  


main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output?

10 Answers   Ramco,


How to print all the 26 alphabets in this order in C. AbCdEfGh..... it should print dynamically from a to z and do not print this using pgm like this print("Ab......"); Use loops or anything to print all alphabets

2 Answers   Hexaware,


What language is lisp written in?

0 Answers  


write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4

1 Answers  


Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not

9 Answers   Alcatel,


Categories