What is the difference between malloc() and calloc() functions?5
1049 5b5cc7dce4d2b419777515ba
Q: What is the difference between malloc() and calloc() functions?
- Show Answer
- Workspace
- Discuss
Answer :
Explanation :
As against malloc(), calloc() needs two arguments, the number of elements to be allocated and the size of each element. For example, p = (int *) calloc (10, sizeof (int)); would allocate space for a 10- integer array. Additionally, calloc() would also set each of this element with a value 0. Thus the above call to calloc() is equivalent to: p = (int *) malloc (10 * sizeof (int)); memset (p, 0, 10 * sizeof( int ));
Similar Questions
Since Nithya and Suganya exchange places, so Rita’s new position is the same as Monika’s earlier position. This position is 17th from the right and 10th from the left. Therefore Number of girls in the row = (16 + 1 + 9) = 26.