difference between malloc and calloc
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / vara
There are two differences.
1) is the number of arguments. Malloc() takes a single
argument (memory required in bytes), while calloc() needs
two arguments (number of variables to allocate memory, size
in bytes of a single variable).
2)malloc() does not initialize the memory allocated, while
calloc() initializes the allocated memory to ZERO.
| Is This Answer Correct ? | 15 Yes | 2 No |
Answer / bijaya
1)malloc() function does not initialize the memory which it
allocates thats why it takes the garbage value.but calloc()
function initializes the allocated memory to zero thats why
it cant take any garbage value.
2)malloc() function takes single arg.that is the variabe
which is used to indicate the memory size to be
allocated.calloc() function takes two args-i) variable which
indicates the number of memory blocks.ii)variable which
indicates the size of each blocks.
| Is This Answer Correct ? | 7 Yes | 0 No |
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
Disadvantages of C language.
When should volatile modifier be used?
what will be maximum number of comparisons when number of elements are given?
int i=~0; uint j=(uint)i; j++; printf(“%d”,j);
Explain what are binary trees?
difference between my-strcpy and strcpy ?
3 Answers Geometric Software, IIM, Infosys,
plz answer..... a program that reads non-negative integer and computes and prints its factorial
Here is a neat trick for checking whether two strings are equal
WAP – represent a char in binary format
Why is not a pointer null after calling free?
What is function pointer c?