difference between malloc and calloc

Answer Posted / namita

1-memory allocated by malloc contains garbage value.But
memory allocated by calloc is initialised to zero.

2-malloc takes only one argument which indicates the size
to be allocated.But calloc takes two arguments.First
argument indicates the number of blocks to be allocated
where as the second argument indicates the size of the
block.

Is This Answer Correct ?    35 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the general description for loop statement and available loop types in c?

689


What is the difference between void main and main in c?

627


Write program to remove duplicate in an array?

604


Explain what is the difference between text files and binary files?

622


What is the use of #include in c?

585






Explain how can I convert a number to a string?

652


What is else if ladder?

614


Why void main is used in c?

564


Explain why c is faster than c++?

579


What are the __date__ and __time__ preprocessor commands?

576


Describe the steps to insert data into a singly linked list.

625


When do we get logical errors?

642


The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.

1637


Explain what is the heap?

626


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1128