What's the difference between calloc() and malloc()?
Answers were Sorted based on User's Feedback
Answer / guest
calloc() takes two arguments, and initializes the allocated
memory to all-bits-0.
Is This Answer Correct ? | 9 Yes | 0 No |
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 |
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 |
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 |
How many types of functions are there in c?
What is the meaning of 2d in c?
write a program that explain #define and # undef directive
What is the difference between printf and scanf in c?
i want to job in your company, so how it will be possible.
What is the difference between local variable and global variable in c?
What is difference between structure and union?
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..
Should I learn c before c++?
How can I implement a delay, or time a users response, with sub-second resolution?
write a function to find whether a string is palindrome or not and how many palindrome this string contain?
Find greatest number out of 10 number without using loop.