Dynamic memory management realloc function

The definition of realloc function in cplusplus.com:

The first parameter of the realloc function is the ptr pointer (pointing to the first address of the starting location we want to expand), and the second parameter is the size space (the size of this space is the size to be expanded plus the original size). 

There are two situations when expanding capacity in space:

code show as below:

Frequent use of the malloc function will cause low efficiency and fragmented space.

Supongo que te gusta

Origin blog.csdn.net/2301_77868664/article/details/130880100
Recomendado
Clasificación