Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C | Dynamic Memory Allocation | Question 6

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Which of the following is true?
(A) “ptr = calloc(m, n)” is equivalent to following
ptr = malloc(m * n);

(B) “ptr = calloc(m, n)” is equivalent to following
ptr = malloc(m * n);
memset(ptr, 0, m * n);

(C) “ptr = calloc(m, n)” is equivalent to following
ptr = malloc(m);
memset(ptr, 0, m);

(D) “ptr = calloc(m, n)” is equivalent to following
ptr = malloc(n);
memset(ptr, 0, n);



Answer: (B)

Explanation: See calloc() versus malloc() for details.


Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads