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

Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

1 Answers  


Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

0 Answers  


How we add our function in liabrary as liabrary function. Exp. we want use our int factorical(int); function as int pow(int,int); function working in math header file.

1 Answers  


How will you allocate memory to a double pointer ?

2 Answers  


What is integer constants?

1 Answers  


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1 Answers  


What is the use of sizeof () in c?

1 Answers  


What are structures and unions? State differencves between them.

1 Answers   iNautix,


What is the use of the sizeof operator?

2 Answers  


If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.

12 Answers   Google,


how memory store byte

4 Answers   Huawei,


What is meant by 'bit masking'?

1 Answers  


Categories