Dynamic Memory Allocation Quiz

What is the return type of malloc() or calloc() ?

A. void *

B. Pointer of allocated memory type

C. void **

D. int *

Solution :

The C library function void *calloc(size_t nitems, size_t size) allocates the requested memory and returns a pointer to it just like the void *malloc(size_t size) The difference in malloc and calloc is that malloc does not set the memory to zero where as calloc sets allocated memory to zero. Both return void*, which is a generic pointer that can point to any type of data

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store