If you need the dynamically allocated memory to be zero-initialized then
use calloc.
If you don't need the dynamically allocated memory to be zero-initialized,
then use malloc.
You don't always need zero-initialized memory; if you don't need the memory
zero-initialized, don't pay the cost of initializing it.
For example, if you allocate memory and then immediately copy data to
fill the allocated memory, there's no reason whatsoever to perform
zero-initialization.
calloc and malloc are functions that do different things: use whichever
one is most appropriate for the task you need to accomplish.
*Note not my answer*
- Answer by James McNellis
(https:
https: