In C and C++, the calloc() function is used

In C and C++, the calloc() function is used for dynamic memory allocation and is defined in the <cstdlib> header. It allocates memory for an array of elements, initializes all bytes to zero, and returns a void* pointer, which must be typecast in C++.

Syntax:
cpp
Copy
Edit
void* calloc(size_t num, size_t size);
num: Number of elements.
size: Size of each element.
Example: Using calloc() in C++
cpp
Copy