Now suppose you've allocated a certain number of bytes for an array but later find that you want to add values to it. You could copy everything into a larger array, which is inefficient, or you can allocate more bytes using realloc, without losing your data.
realloc takes two arguments. The first is the pointer referencing the memory. The second is the total number of bytes you want to reallocate.
Passing zero as the second argument is the equivalent of calling free.
Once again, realloc returns a void pointer if successful, else a NULL pointer is returned. "
i understood that realloc stitches a new sector of empty cell data to and old one.
first we have an old array of 5 integers cells
ptr = calloc(5, sizeof(int));
we fill it with data and then we want to expand it with 7 new integer cells
we take the old ptr and this command by 7 integers cells
ptr = realloc(ptr, 7*sizeof(int));
is it correct?