which function is better calloc or malloc ?

It depends on what you want. calloc(...) additionally sets the memory to 0. See:

https://www.cplusplus.com/reference/cstdlib/calloc/
Calloc also allows to specify the number of items and the size of each item. With malloc you have to explicitly do the calculation.

Is this for c or C++? In C++ don't use these. Use new/delete.
For C++? Neither, you should be using new.

For C? Probably calloc since it initializes memory to 0 which is free or next to free on modern systems. This allows you to design data structures such that a zero-initialized struct is an invariant and "uninitialized" structs allocated on the heap are not possible. This is not necessary in C++ since we have the new operator and construtors, but that can be useful in C.
Registered users can post here. Sign in or register to post.