Dynamic memory management calloc function

The calloc function is also a function for dynamic memory allocation. The definition of the calloc function in cplusplus.com:

There are two parameters: num, size. num is the number of elements to be allocated, and size is the size of the elements to be allocated. To be distinguished from malloc parameters. The calloc function will be initialized to 0 after opening up the space; 

If you want to initialize, use calloc. If you don't want to initialize, use malloc.

calloc = malloc + memset 

Guess you like

Origin blog.csdn.net/2301_77868664/article/details/130875247